Django column “name” of relation “django_content_type” does not exist

后端 未结 8 1832
忘了有多久
忘了有多久 2020-12-23 14:31

I keep getting the following error when doing a migration (python manage.py migrate):

django.db.utils.ProgrammingError: column \"name\" of relation \"django_         


        
8条回答
  •  清酒与你
    2020-12-23 14:52

    Encountered this when upgrading to 1.8 and migrating from MySQL to Postgres.

    I can't explain why the error occurs, but I was able to get around it by manually adding the column:

    1. Delete all migrations

    2. Delete records from django_migrations

    3. Manually add name column:

      ALTER TABLE django_content_type ADD COLUMN name character varying(50) NOT NULL DEFAULT 'someName';
      
    4. Run fake initial: $ python manage.py migrate --fake-initial

    Edit 12/2016: I'm recommending this as a workaround, more suited for personal projects or local environments and not production environments. Obviously if you care about your migration history this is not the way to go.

提交回复
热议问题