I have myApp/models/profiles.py
instead of myApp/models.py
(to group related models)
How do you set AUTH_USER_MODEL in this case?
Because auth accepts only "foo.bar" pattern.
app_label, model_name = settings.AUTH_USER_MODEL.split('.')
Django expects the models for any given app to be in app.models
. If you want to use this kind of file structure, you'll need to still make sure this is the case. The easiest way to do this is too add from profiles import *
in myApp/models/__init__.py
and then use AUTH_USER_MODEL
as normal.
For example, you you had myApp/models/profiles.py
and myApp/models/actions.py
your myApp/models/__init__.py
should read
from profiles import *
from actions import *
Remember to make sure you don't have any name conflicts too, and you may wish to use set your __all__
value in each of your sub-packages.
You can either pass the class directly or the 'app.model'. django only registers classes defined in app.models
module, so you'll need to import the class in models
init
. Since you'll be importing the model in init
anyway, you don't need to specify the full path to the class in the foreignkey.