0
在Django中使用自定義用戶模型就像生活在地獄一樣。花費無數的時間努力完成它之後,我現在面臨着新的問題:一旦我添加一些其他的應用程序,取決於我的自定義用戶模式,我看到這一點: 例如有一次我加'django.contrib.admin'
,我看到錯誤字段定義與模型'MODEL'的關係,該模型或者未安裝,或者是抽象的
admin.LogEntry.user: (fields.E300) Field defines a relation with model 'main.Usr', which is either not installed, or is abstract.
admin.LogEntry.user: (fields.E307) The field admin.LogEntry.user was declared with a lazy reference to 'main.usr', but app 'main' doesn't provide model 'usr'.
我的設置是一樣
AUTH_USER_MODEL = 'main.Usr'
INSTALLED_APPS = [
'django.contrib.auth',
'main', # my app
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.staticfiles',
'debug_toolbar',
'django.contrib.postgres',
]
不知道這是否會有所作爲,但嘗試將您的應用程序移動到列表的底部。 –