#2445: allow callable values for limit_choices_to -----------------------------------+---------------------------------------- Reporter: [EMAIL PROTECTED] | Owner: adrian Type: enhancement | Status: new Priority: normal | Milestone: Component: Core framework | Version: Severity: normal | Resolution: Keywords: | -----------------------------------+---------------------------------------- Comment (by [EMAIL PROTECTED]):
I took another look - I only have limited familiarity with the code. The value of limit_choices_to is passed to complex_filter() in three places: {{{ django/contrib/admin/views/main.py django/db/models/manipulators.py django/db/models/fields/__init__.py }}} I believe that calls to complex_filter() are the only places limit_choices_to is actually used. The limit_choices_to is always obtained via referencing some fragment such as .rel.limit_choices_to The "rel" class needs a method (hopefully in some base class) that evaluates its' limit_choices_to and returns a new hashmap: {{{ def get_limit_choices_to(self): limiters = {} if self.limit_choices_to: for id in self.limit_choices_to: value = self.limit_choices_to[id] if callable(value): value = value() limiters[id] = value return limiters }}} The existing direct references to ref.limit_choices_to need to change to ref.get_limit_choices_to() Does this sound like I'm on the right track? I'm proceeding on these lines for now. -- Ticket URL: <http://code.djangoproject.com/ticket/2445> Django <http://code.djangoproject.org/> 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-updates -~----------~----~----~----~------~----~------~--~---