Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dependency on app with no migrations: %s" % key[0]) in the Django

I need create custom user. I'm using a user model with AbstractUser:

from django.contrib.auth.models import AbstractUser
from django.db import models
from django.utils.html import escape, mark_safe


class User(AbstractUser):
    is_student = models.BooleanField(default=False)
    is_teacher = models.BooleanField(default=False)

settings.py:

INSTALLED_APPS = [
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.humanize',

    'crispy_forms',

    'backend.classroom',
]

I believe that problem is in the following line:

AUTH_USER_MODEL = 'classroom.User'

error:

File "/home/davi/.local/share/virtualenvs/django-vue-template-Wl6a6m2J/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 82, in handle
    executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "/home/davi/.local/share/virtualenvs/django-vue-template-Wl6a6m2J/lib/python3.6/site-packages/django/db/migrations/executor.py", line 18, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/home/davi/.local/share/virtualenvs/django-vue-template-Wl6a6m2J/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in __init__
    self.build_graph()
  File "/home/davi/.local/share/virtualenvs/django-vue-template-Wl6a6m2J/lib/python3.6/site-packages/django/db/migrations/loader.py", line 226, in build_graph
    self.add_external_dependencies(key, migration)
  File "/home/davi/.local/share/virtualenvs/django-vue-template-Wl6a6m2J/lib/python3.6/site-packages/django/db/migrations/loader.py", line 191, in add_external_dependencies
    parent = self.check_key(parent, key[0])
  File "/home/davi/.local/share/virtualenvs/django-vue-template-Wl6a6m2J/lib/python3.6/site-packages/django/db/migrations/loader.py", line 173, in check_key
    raise ValueError("Dependency on app with no migrations: %s" % key[0])
ValueError: Dependency on app with no migrations: classroom

obs: The app classrom app is in the backend folder. I tried the following code too:

AUTH_USER_MODEL = 'backend.classroom.User'
like image 722
Davi Luis Avatar asked Oct 15 '25 07:10

Davi Luis


1 Answers

Try creating the initial migration for the classroom app before declaring it as AUTH_USER_MODEL, as anything that would ordinarily depend on auth.User now depends on classroom.User.

$ python manage.py makemigrations classroom
like image 194
AKX Avatar answered Oct 16 '25 21:10

AKX



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!