User in django raises ValueError

Even this simple example throws ValueError: Dependency on app with no migrations: myApp during python manage.py syncdb

MYAPP / models.py

 from django.contrib.auth.models import AbstractUser class User(AbstractUser): pass 

settings.py

 AUTH_USER_MODEL = 'myApp.User' 

Doing ./manage syncdb in django == 1.6.5 <work

 Creating tables ... 

Running ./manage syncdb in django == 1.7 <breaks

 Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/Users/bdhammel/Documents/web_development/tutorials/python_social_auth/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line utility.execute() File "/Users/bdhammel/Documents/web_development/tutorials/python_social_auth/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/bdhammel/Documents/web_development/tutorials/python_social_auth/env/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv self.execute(*args, **options.__dict__) File "/Users/bdhammel/Documents/web_development/tutorials/python_social_auth/env/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute output = self.handle(*args, **options) File "/Users/bdhammel/Documents/web_development/tutorials/python_social_auth/env/lib/python2.7/site-packages/django/core/management/base.py", line 533, in handle return self.handle_noargs(**options) File "/Users/bdhammel/Documents/web_development/tutorials/python_social_auth/env/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 27, in handle_noargs call_command("migrate", **options) File "/Users/bdhammel/Documents/web_development/tutorials/python_social_auth/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 115, in call_command return klass.execute(*args, **defaults) File "/Users/bdhammel/Documents/web_development/tutorials/python_social_auth/env/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute output = self.handle(*args, **options) File "/Users/bdhammel/Documents/web_development/tutorials/python_social_auth/env/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 63, in handle executor = MigrationExecutor(connection, self.migration_progress_callback) File "/Users/bdhammel/Documents/web_development/tutorials/python_social_auth/env/lib/python2.7/site-packages/django/db/migrations/executor.py", line 17, in __init__ self.loader = MigrationLoader(self.connection) File "/Users/bdhammel/Documents/web_development/tutorials/python_social_auth/env/lib/python2.7/site-packages/django/db/migrations/loader.py", line 48, in __init__ self.build_graph() File "/Users/bdhammel/Documents/web_development/tutorials/python_social_auth/env/lib/python2.7/site-packages/django/db/migrations/loader.py", line 239, in build_graph parent = self.check_key(parent, key[0]) File "/Users/bdhammel/Documents/web_development/tutorials/python_social_auth/env/lib/python2.7/site-packages/django/db/migrations/loader.py", line 163, in check_key raise ValueError("Dependency on app with no migrations: %s" % key[0]) ValueError: Dependency on app with no migrations: myApp 

I could not find anything in the documentation for 1.7, which says that this should be done differently than 1.6. It looks like some other people have this problem too , but as a result of running ./manage.py migrate --list

Has anyone come across this?

+6
source share
3 answers

I guess I was looking for an inappropriate place to answer:

I solved this by doing: ./manage.py makemigrations myApp

 (env)Bens-MacBook-Pro:social_auth bdhammel$ ./manage.py makemigrations myApp Migrations for 'myApp': 0001_initial.py: - Create model User (env)Bens-MacBook-Pro:social_auth bdhammel$ python manage.py syncdb Operations to perform: Apply all migrations: sessions, admin, myApp, auth, default, contenttypes Running migrations: Applying contenttypes.0001_initial... FAKED Applying auth.0001_initial... FAKED Applying app.0001_initial... FAKED Applying admin.0001_initial... FAKED Applying default.0001_initial... FAKED Applying sessions.0001_initial... FAKED You have installed Django auth system, and don't have any superusers defined. Would you like to create one now? (yes/no): yes 

via https://docs.djangoproject.com/en/1.7/topics/migrations/#s-custom-fields

EDIT
I would use python manage.py migrate instead of python manage.py syncdb .

https://docs.djangoproject.com/en/1.8/releases/1.7/#schema-migrations

syncdb is deprecated and replaced by migration. Do not worry - syncdb calls will work as before.

+20
source
  • Delete migration folder in each application
  • Delete django_migrations table
  • Run python3 manage.py makemigrations app1
  • Run python3 manage.py makemigrations app2

manage.py runserver should now work like a charm

+5
source

This happened to me when I moved the application to a clean new project without deleting the migration. If you don’t care about migration and start the project from scratch, consider removing migrations from these applications.

0
source

Source: https://habr.com/ru/post/976280/


All Articles