Changes between Version 1 and Version 2 of Ticket #25306, comment 2


Ignore:
Timestamp:
Aug 24, 2015, 6:14:45 PM (9 years ago)
Author:
Tim Graham

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #25306, comment 2

    v1 v2  
    11Thanks for the pointer Tim! I've been digging into the admin code, because I honestly hadn't needed to before. I'm sure that what you mentioned will end up being what I have to do. But part of the point of Django admin seems to be that people don't end up having to dive into the code for an admin interface when they're building a website. Hence why there are options like blank and limit_choices_to on fields. The suggestion in this feature request is that model fields have something similar to limit_choices_to. Perhaps this parameter could be passed a function. When a ForeignKey is populated in a change view, this function could be passed the relevant instance, and could return a queryset to filter on.
    22
    3 Perhaps this could be done by adding the behavior described to limit_choices_to? I believe this would involve modifying the __init__ method of forms.models.BaseModelForm
     3Perhaps this could be done by adding the behavior described to limit_choices_to? I believe this would involve modifying the `__init__` method of `forms.models.BaseModelForm`.
Back to Top