Ved-форум поддержки

Программирование => Django => Тема начата: AdminUser от Мая 12, 2019, 03:07:55 pm

Название: Ошибка при переносе моделей из models.py в model
Отправлено: AdminUser от Мая 12, 2019, 03:07:55 pm
Решил перенести модели из models.py в папку models. Скопировал, создал __init__.py. Переименовал models.py в users.py.

В settings.py изменил на

AUTH_USER_MODEL = 'main.users.Profile'
Получаю ошибку:
Цитата:
  File "D:\django\hello\lib\site-packages\django\db\models\utils.py", line 23, i
n make_model_tuple
    "must be of the form 'app_label.ModelName'." % model
ValueError: Invalid model reference 'main.users.Profile'. String model reference
s must be of the form 'app_label.ModelName'.

Если пишу как раньше:

AUTH_USER_MODEL = 'main.Profile'
То получаю

Цитата:
auth_user_model refers to model 'main.Profile' that has not been installed
Название: Re: Ошибка при переносе моделей из models.py в model
Отправлено: DigitalMag от Мая 12, 2019, 04:17:54 pm
Сделайте импорт в __init__.py:
from .users import *