Monday, October 20, 2014

Specifying modelform meta field as get_user_model() in 1.7

Hi,

I'm working on porting our codebase to django 1.7, and we use a custom user model. For that, we need to override the user creation and password reset forms. 
For the form's Meta class, we have

class Meta:
    model
= get_user_model()


where get_user_model is imported form django.contrib.auth. Because of changes made in 1.7, that can no longer be called at import time because the app registry is not ready. The troubleshooting section of the 1.7 update notes suggests using settings.AUTH_USER_MODEL instead, however that doesn't work in this case, as far as I can tell. 

The only workaround I have come up with is simply to directly reference the custom user model. This will probably work fine for us, but it seems like it could cause problems for libraries, since they wont know what the custom model is. Is there a workaround for this? I'm not sure if I am just missing something.

thanks

--Derek Leverenz

--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2e1a3233-eee9-4cc3-928e-ff77fcc50bc9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment