On Wed, 8 Jan 2020 at 20:09, Ezequias Rocha <ezequias.rocha@gmail.com> wrote:
Hi everyoneI am in a doubt about creating django filters dynamically.All you know a filter is made by using the parameters like:model.filter(name='John', age=42)But if I can't type all fields and values at design time but at runtime how to do that?
Populate a dictionary with what you need and pass that in:
query = {'name': 'John', 'age': 42}
model.filter(**query)
--Best regardsEzequias
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9c843d02-235f-411f-8e83-7fea2156893b%40googlegroups.com.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHAc2jfQDKCv8gtqsnmJJrRm1XPvRp%3DCCQ3nP_3b8D16oyw65w%40mail.gmail.com.
No comments:
Post a Comment