Sunday, April 28, 2013

Re: Must AUTH_USER_MODEL be in "models.py"?

I wouldn't use "import *" if I were you. I would put the imports in the models.py file rather than in _models/__init__.py

Not sure if that will save your problem but might be worth trying it out.

On Sunday, 28 April 2013 17:17:07 UTC+10, Richard Eames wrote:
I like to split my models up into separate files, but it seems that the new customizable user model requires that it is defined directly in a "models.py" file. 

A condensed version of my project structure and code:
manage.py
project/
   app1/
      models.py "from _models import *"
      _models/
        __init__.py "from .model1 import MyUser"
        model1.py
    settings.py

model1.py:
class MyUser(AbstractBaseUser): 
    <some code>

settings.py
INSTALLED_APPS = ('project.app1', )
AUTH_USER_MODEL = 'app1.MyUser'

The above gives me:
auth.user: Model has been swapped out for 'app1.MyUser' which has not been installed or is abstract.

If I move the definition of MyUser into app1/models.py then it works. 

Am I missing something, or is this a bug?

--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment