python - When is django.conf.global_settings loaded? -


I created a custom user model using the "AbstractUser" model. conf.global_settings import from ajango AUTH_USER_MODEL MyCustomUser (AbstractUser): regions = models. ManyToManyField (= 'some models') class meta: app_label = 'myapp' MyObject (models.Model): Owner = models.ForeignKey (= AUTH_USER_MODEL)

and I have set AUTH_USER_MODEL to settings / base.py (I file Ex: settings / base.py, settings / develop.py) in the settings of each environment.

  AUTH_USER_MODEL = 'myapp.MyCustomUser'   

When I executed the python manage.py syncdb , my console window is deegen Has been flared by!

  myapp.MyObject: The 'owner' model defines a relationship with 'auth.User', which has been swapped out. Update the relationship to point to the setting AUTH_USER_MODEL   

So, I have two questions.

  1. What is the problem is that I have separated each setting from the settings.
  2. Code> django.global_settings import AUTH_USER_MODEL import myproject.settings ?

    and I myproject.settings.base import from AUTH_USER_MODEL at this time.

    global_settings , as the name implies, The default settings are definitely the default 'auth.user'.

    Since you override it in your settings, you should import it instead. But as the documentation says, the method of importing an existing setting is always, instead of importing the settings file into your project, there is from .

    Also note that instead of using everyone's settings here - which may be due to some dependency issue at startup - you can get from get_user_model () to django .contrib.auth should be used, as explained in.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -