RuntimeError: error creating new content types

Operations to perform: Synchronize unmigrated apps: google, staticfiles, twitter, messages, reflect, allauth, facebook, rest_framework, crispy_forms Apply all migrations: account, django_comments, links, sessions, admin, fluent_comments, sites, auth, contenttypes, socialaccount Synchronizing apps without migrations: Creating tables... Running deferred SQL... Installing custom SQL... Running migrations: No migrations to apply. Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "C:\Users\Home\venv\lib\site-packages\django\core\management\__init__.py", line 338, in execute_from_command_line utility.execute() File "C:\Users\Home\venv\lib\site-packages\django\core\management\__init__.py", line 330, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Users\Home\venv\lib\site-packages\django\core\management\base.py", line 390, in run_from_argv self.execute(*args, **cmd_options) File "C:\Users\Home\venv\lib\site-packages\django\core\management\base.py", line 441, in execute output = self.handle(*args, **options) File "C:\Users\Home\venv\lib\site-packages\django\core\management\commands\migrate.py", line 225, in handle emit_post_migrate_signal(created_models, self.verbosity, self.interactive, connection.alias) File "C:\Users\Home\venv\lib\site-packages\django\core\management\sql.py", line 280, in emit_post_migrate_signal using=db) File "C:\Users\Home\venv\lib\site-packages\django\dispatch\dispatcher.py", line 201, in send response = receiver(signal=self, sender=sender, **named) File "C:\Users\Home\venv\lib\site-packages\django\contrib\auth\management\__init__.py", line 82, in create_permissions ctype = ContentType.objects.db_manager(using).get_for_model(klass) File "C:\Users\Home\venv\lib\site-packages\django\contrib\contenttypes\models.py", line 78, in get_for_model "Error creating new content types. Please make sure contenttypes " RuntimeError: Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually. 

I tried removing db and makemigrations and then migrate . Same error

Then I tried migrate contenttypes to migrate . There are no changes to the trace.

What's wrong?

I am using django == 1.8

+5
source share
2 answers

I just ran into the same error message. In my case, this was after I introduced additional fields in the Django group model. Maybe you are doing something similar. The problem is that the auth migration created for the modified Group model is in the pip package folder of Django.

I found it in:

 <my_env_folder>/lib/python3.4/site-packages/django/contrib/auth/migrations/0007_auto_20151118_1635.py 

You can add it as a dependency on a failed migration:

 dependencies = [ ('auth', '0007_auto_20151118_1635'), ('accounts', '0001_admin_user'), ] 

But this will fail when restoring env from scratch. So this is not a solution: - /.

0
source

In my case, this was due to the https://code.djangoproject.com/ticket/25100 error. For some reason, the migration contenttypes.0002_remove_content_type_name not completed, the bid is marked as completed. To fix this, I simply deleted the name field manually using this query:

 alter table django_content_type drop column name; 

After this migration began to work.

0
source

All Articles