Thursday, May 18, 2017

Re: Signal limitations with custom models!

Thanks man! Actually i was thinking the same thing as mentioned in the question because that's the only valid logical reason i can come up with after viewing the ticket. Anyways Thanks again

On Thursday, May 18, 2017 at 2:53:57 AM UTC+5, James Schneider wrote:


On May 17, 2017 7:59 AM, "Uzair Tariq" <s.uzai...@gmail.com> wrote:
So i read about Signal Limitations in Django that comes up with user custom models and you can't use get_user_model() as according to this link it's clearly stated that the reason for it is because the module is not completely loaded at this point and the solution is to defer the function call until the whole module is loaded. So why not this case does not apply to Default user model i.e. AbstractUser in django? Is it because of execution order or is it some back end One Time execution logic that loads the default models only once in a cache and retrieves it every time but not in custom user model case?

From my brief reading of the ticket, it looks like the signal call for the built-in User (not AbstractUser, which is never directly used) only works because that model is already loaded by the time the custom models are inspected. 

My guess is that the internal Django models are loaded first, and then app models are loaded. Since you're defining the signal handler in your app, you would be able to reference the built-in models but not any models that haven't already been inspected. 

I doubt there is any magic involved, it's technically a race condition.

Admittedly, I'm not deeply familiar with the mechanics in this scenario, but it's my best educated guess.

-James


--
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/30421fe9-a1e5-47b2-8f72-d348639a255e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment