48
I think this has something to do with “The removal of ContentType.name
“, according to this. But somehow it doesnt work.
By manually removing the column name
from ‘django_content_type’ table. Eg.
'ALTER TABLE django_content_type DROP COLUMN name'
I was able to apply the migrations. Maybe this can get you a little bit further at least.
18
Try to migrate auth application first, and then others:
manage.py migrate auth
manage.py migrate <app_name>
- [Django]-Django Template Ternary Operator
- [Django]-Writing test cases for django models
- [Django]-Django admin and MongoDB, possible at all?
7
In my case, what i did to fix this was updating to a newer version of django.
If you work with mac just do:
- pip install django –upgrade
- python manage.py makemigrations
- python manage.py migrate
- [Django]-Django-admin.py makemessages not working
- [Django]-Why does Django REST Framework provide different Authentication mechanisms
- [Django]-How to create password input field in django
3
May look strange but I fixed this by upgrading to Django version 1.8.
Initially i was using ver 1.7
- [Django]-How can I change the modelform label and give it a custom name
- [Django]-Oauth for Google API example using Python / Django
- [Django]-Remove duplicates in a Django query
2
To add to comment by @int_ua
Add this as a dependency to the migration that is failing:
dependencies = [
('contenttypes', '0002_remove_content_type_name'),
]
Then run migration again.
- [Django]-TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'
- [Django]-How do you return 404 when resource is not found in Django REST Framework
- [Django]-Duplicating model instances and their related objects in Django / Algorithm for recusrively duplicating an object
2
I had to merge two systems in Django 1.9.1 and I just could not get past this error:
"Error creating new content types. Please make sure contenttypes "
Extensive googling and stackoverflowing was fruitless. Finally, I added the the debug line to
~/.virtualenvs/(venv_name)/lib/python2.7/site-packages/django/contrib/contenttypes/models.py
except (OperationalError, ProgrammingError, IntegrityError):
# It's possible to migrate a single app before contenttypes,
# as it's not a required initial dependency (it's contrib!)
# Have a nice error for this.
print "\n\nError for Content type model "+opts.model_name+"\n\n"
raise RuntimeError(
"Error creating new content types. Please make sure contenttypes "
"is migrated before trying to migrate apps individually."
)
This told me the model names that were causing the error and ultimately led to the fix.
I am using Postgres and the sequence numbers for tables django_content_type and auth_permission were not pointing to the end of the table, causing inserts to fail.
These 2 lines fixed that (based on this SO post)
SELECT pg_catalog.setval(pg_get_serial_sequence('django_content_type', 'id'), (SELECT MAX(id) FROM django_content_type)+1);
SELECT pg_catalog.setval(pg_get_serial_sequence('auth_permission', 'id'), (SELECT MAX(id) FROM auth_permission)+1);
- [Django]-Custom django admin templates not working
- [Django]-Django get objects not referenced by foreign key
- [Django]-How to execute a Python script from the Django shell?