#27563: Move "Apply limit_choices_to" code from BaseModelForm to
fields_for_model()
--------------------------------------+------------------------------------
Reporter: Jon Dufresne | Owner: nobody
Type: Cleanup/optimization | Status: closed
Component: Forms | Version: 1.11
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Comment (by drunkard):
This change breaks inheriting from django.forms.models.ModelForm directly.
I'm upgrading to python3.6 + django-1.11.2, and gets wrong with this
commit. I'm using dynamic limit_choices_to function to get user specific
filter expr, one of my function is like:
{{{
def limit_export_branch():
user = current_user()
if user:
bs = user.userprofile.branches_with_perms(['add_export',
'change_export'])
return Q(pk__in=bs.values_list('pk', flat=True),
businesses__name=BUSINESS_BROADBAND)
return Q(pk=-1) # deny to avoid info leak
}}}
It just called once during develop server init, and won't be call while
open a USER EDIT FORM, but it work in django admin edit page, by reading
the code, django admin build form using modelform_factory(), with this
commit reverted, my customized form works just fine. So, I think it's a
regression.
Or, the usage of ModelForm changed? but newest doc not mentioned.
--
Ticket URL: <https://code.djangoproject.com/ticket/27563#comment:10>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.ad8cdd5b930c0823c7a46186a6541d76%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.