Wednesday, June 28, 2017

limit_choices_to=function() not work in python-3.6+django-1.11.2

Hi, fellows:

I was running python-3.4+django-1.9.13 previous, and upgrading to python-3.6+django-1.11.2, while testing, I found that my limit_choices_to function not working now, here's detail.

I'm using a middleware to get current user who is accessing my site, and use it in limit_choices_to function, to provide different filter based on current user. This works great with python-3.4 + django-1.9.13; and using django-crispy-forms to render user forms.

After upgraded to python-3.6+django-1.11, limit_choices_to function didn't called when I opened a USER EDIT FORM (by adding print() to the function), but it still works with django admin.

So the question is:
1. The difference of init procedures between django 1.9.13 and 1.11.2? Because 1.9.13 won't exec limit_choices_to function on init, while 1.11.2 does.
2. Where should I fix the problem? django init settings, my form, or even django-crispy-forms?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/720cfbc1-d941-4e3b-8cbe-3a7eae116f6f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment