I wanted to write to the mailing list about this problem. Thanks for bringing it up.
Here’s what happens. Django 1.7 is more strict about the import sequence. Technically, the app registry population process isn't re-entrant anymore. As a consequence, it isn’t possible to call get_user_model() until the app registry is fully populated, that is, until all app packages and models modules have been imported. A milder variant of this problem existed in Django 1.6. The docs recommend using settings.AUTH_USER_MODEL rather than get_user_model() as the target of ForeignKeys. In fact, you could get away with get_user_model(), but you started depending on the app registry population sequence, which wasn’t deterministic. The most straightforward solution is to document under which conditions get_user_model() works. Technically, it works once all models modules have been imported. It can’t be used in models.py, but for example, it can be used in forms.py, assuming models.py doesn’t import forms.py. I don’t know the implementation of custom user models very well. Can someone confirm whether this restriction is acceptable, or whether it makes get_user_model() useless? An alternative is to have get_user_model() return a proxy object, but I really don’t like such hacks. -- Aymeric. -- You received this message because you are subscribed to the Google Groups "Django developers" 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]. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/56848555-93F3-4B6A-8953-B59B472F50D3%40polytechnique.org. For more options, visit https://groups.google.com/groups/opt_out.
