#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: [email protected] | Owner: DrMeers
Status: assigned | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday
list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by foxwhisper):
* needs_better_patch: 0 => 1
Comment:
I fixed this by changing:
django/contrib/admin/util.py
{{{
#!python
def get_limit_choices_to_from_path(model, path):
""" Return Q object for limiting choices if applicable.
If final model in path is linked via a ForeignKey or ManyToManyField
which
has a `limit_choices_to` attribute, return it as a Q object.
"""
fields = get_fields_from_path(model, path)
fields = remove_trailing_data_field(fields)
+ if len(fields)==0:
+ return models.Q()
limit_choices_to = (
hasattr(fields[-1], 'rel') and
getattr(fields[-1].rel, 'limit_choices_to', None))
if not limit_choices_to:
return models.Q() # empty Q
elif isinstance(limit_choices_to, models.Q):
return limit_choices_to # already a Q
else:
return models.Q(**limit_choices_to) # convert dict to Q
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:64>
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.