Specifying modelform meta field as get_user_model() in 1.7

36 views
Skip to first unread message

Derek Leverenz

unread,
Oct 20, 2014, 7:21:59 PM10/20/14
to django...@googlegroups.com
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

Collin Anderson

unread,
Oct 21, 2014, 10:21:03 AM10/21/14
to django...@googlegroups.com
Hi Derek,

Interesting. Do you know why it's trying to import your form before the app registry is ready? It seems to me it might be possible to delay until after the app registry is ready. Could you post a traceback?

Thanks,
Collin

Reply all
Reply to author
Forward
0 new messages