Django == 3.0.6
Github: https://github.com/Kifsif/pcask
/ категория / models.py
class Category(CommentMixin,
TitleMixin,
SlugMixin,
models.Model):
pass
from category.models import Category
/ post / models.py
class Post(TitleMixin,
SlugMixin,
DescriptionMixin,
models.Model):
...
category = models.ForeignKey(Category,
on_delete=models.PROTECT,
related_name='blog_posts')
База данных была удалена и создана заново. Все миграции удалены. В settings.py добавляются 'post' и 'category'.
При миграции:
(venv) michael@michael:~/PycharmProjects/pcask/pcask$ python manage.py makemigrations
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/home/michael/PycharmProjects/pcask/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/home/michael/PycharmProjects/pcask/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/michael/PycharmProjects/pcask/venv/lib/python3.6/site-packages/django/core/management/base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/michael/PycharmProjects/pcask/venv/lib/python3.6/site-packages/django/core/management/base.py", line 369, in execute
output = self.handle(*args, **options)
File "/home/michael/PycharmProjects/pcask/venv/lib/python3.6/site-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/home/michael/PycharmProjects/pcask/venv/lib/python3.6/site-packages/django/core/management/commands/makemigrations.py", line 168, in handle
migration_name=self.migration_name,
File "/home/michael/PycharmProjects/pcask/venv/lib/python3.6/site-packages/django/db/migrations/autodetector.py", line 43, in changes
changes = self._detect_changes(convert_apps, graph)
File "/home/michael/PycharmProjects/pcask/venv/lib/python3.6/site-packages/django/db/migrations/autodetector.py", line 129, in _detect_changes
self.new_apps = self.to_state.apps
File "/home/michael/PycharmProjects/pcask/venv/lib/python3.6/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/michael/PycharmProjects/pcask/venv/lib/python3.6/site-packages/django/db/migrations/state.py", line 209, in apps
return StateApps(self.real_apps, self.models)
File "/home/michael/PycharmProjects/pcask/venv/lib/python3.6/site-packages/django/db/migrations/state.py", line 279, in __init__
raise ValueError("\n".join(error.msg for error in errors))
ValueError: The field post.Post.category was declared with a lazy reference to 'category.category', but app 'category' doesn't provide model 'category'.
Мои классы миксинов выглядят так:
class CommentMixin():
comment = models.TextField(default="", blank=True)
class Meta:
abstract = True
Не могли бы вы помогите мне понять, что здесь происходит?