#15606: Django admin filter and Bool choices ---------------------------+--------------------------- Reporter: django@… | Owner: nobody Status: new | Milestone: Component: Uncategorized | Version: 1.2 Keywords: | Triage Stage: Unreviewed Has patch: 0 | ---------------------------+--------------------------- If I have such construction:
{{{ #!python # models.py class BoolTest(models.Model): NO = False YES = True YES_NO_CHOICES = ( (NO, 'no'), (YES, 'yes') ) completed = models.BooleanField( default=NO, choices=YES_NO_CHOICES # admin.py class BoolTestAdmin(admin.ModelAdmin): list_filter = ('completed',) }}} and I use filter results in Django admin, then this URL is generated (for `no` and `yes` choices): .../admin/appname/booltest/?completed!__exact=False[[br]] .../admin/appname/booltest/?completed!__exact=True The !True/False is taken as string (not converted 'True' -> True and 'False' -> False), non empty strings in Python are considered as True, so the final SQL is for both choices: SELECT `appname_booltest`.`id`, `appname_booltest`.`name`, `appname_booltest`.`completed` FROM `appname_booltest` WHERE `appname_booltest`.`completed` = 1 ORDER BY `appname_booltest`.`id` DESC I think, that instead of !True/False there should be 0/1 in URL -- Ticket URL: <http://code.djangoproject.com/ticket/15606> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.