2

I've dropped my Postgres database by accident. Then as per this solution I deleted the migration files but now can't execute the third step's command "python manage.py migrate --fake".

RuntimeError: Error creating new content types. 
Please make sure contenttypes is migrated before trying to migrate apps individually.


psycopg2.ProgrammingError: relation "django_content_type" does not exist
LINE 1: ..."."app_label", "django_content_type"."model" FROM "django_co...
                                                         ^

I tried running "python manage.py migrate contenttypes" and "python manage.py makemigrations contenttypes --empty" but neither work.

Using django 1.9.5

2

1 Answer 1

-1

Synchronise your project first: like this:

python manage.py syncdb

when finish you can run: python manage.py makemigrations and last python manage.py migrate

6
  • python manage.py syncdb returns "Unknown command: 'syncdb'". I tried doing python manage.py migrate --run-syncdb but that returned the exact same thing as just "migrate"
    – Naarkie
    Apr 24, 2016 at 16:27
  • wath django version you have ?
    – Fabe
    Apr 24, 2016 at 17:10
  • I'm using Django 1.9.5
    – Naarkie
    Apr 24, 2016 at 18:35
  • If you have django 1.9 use makemigrations like this: python manage.py makemigrations; syncdb removed in 1.9 you must use makemigrations and migrate (python manage.py migrate). Don't forget add s in makemigrations command.
    – Fabe
    Apr 24, 2016 at 19:59
  • Yes I've done the standard makemigrations and then migrate. After makemigrations I get "no changes detected" and after migrate I get the contenttypes error like in my original post
    – Naarkie
    Apr 25, 2016 at 8:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.