must be of the form 'app_label.ModelName'." % model ValueError: Invalid model reference

后端 未结 3 1996
长发绾君心
长发绾君心 2021-01-14 17:40

When I python3 manage.py makemigrations, I get bellow error:

...

  File \"/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-         


        
3条回答
  •  无人及你
    2021-01-14 17:41

    Has a bit different situation with the same error message:

    ValueError: Invalid model reference 'users.models.MyUser'. String model references must be of the form 'app_label.ModelName'.

    The error was that I've specified models in the path to the MyUser model:

    AUTH_USER_MODEL = 'users.models.MyUser'
    

    But we shouldn't do it, we just need specify the package and model name only

    AUTH_USER_MODEL = 'users.MyUser'
    

    And error is gone.

提交回复
热议问题