Tuesday, March 24, 2015

Re: ProgrammingError: relation "django_content_type" already exists

Still not getting very far. The error below* keeps turning up. Further
to this, I ran migrate with --list and --settings=ssds.settings.dev and
it returns ...

admin
[ ] 0001_initial
auth
[ ] 0001_initial
[ ] 0002_alter_permission_name_max_length
[ ] 0003_alter_user_email_max_length
[ ] 0004_alter_user_username_opts
[ ] 0005_alter_user_last_login_null
[ ] 0006_require_contenttypes_0002
contenttypes
[ ] 0001_initial
[ ] 0002_remove_content_type_name
sessions
[ ] 0001_initial
sites
[ ] 0001_initial

The 1.7 docs say ...

The --list option will list all of the apps Django knows about, the
migrations available for each app and if they are applied or not (marked
by an [X] next to the migration name).

Apps without migrations are also included in the list, but will have (no
migrations) printed under them.

None of my five apps are listed.

Running makemigrations returns "No changes detected" so I suppose the
Django ones were done when I first ran manage.py migrate. That's only a
guess.

I'll keep reading the docs.

Thanks in advance

Mike

* see below

On 24/03/2015 5:00 PM, Mike Dewhirst wrote:
> This is my first stab at upgrading directly from Django 1.6.11 to 1.81c
> to see what needs to be done. I thought I'd skip 1.7.x - is that a bad
> idea? Is there some step in 1.7.x which eases the path to 1.8.x?
>
> On first starting the project up using runserver on localhost it advises:
>
> Python: 3.4
> Django: 1.8c1
> Database: ssds.climate.com.au
> Postgres: 9.1
> 16:18:54
>
> Performing system checks...
>
> System check identified no issues (0 silenced).
>
> You have unapplied migrations; your app may not work properly until they
> are applied.
> Run 'python manage.py migrate' to apply them.
>
> See below. Not sure where to go from here. Any ideas?
>
> Thanks
>
> Mike
>
> On running manage.py migrate it returns a ProgrammingError as follows:
>
> (xxex3) C:\Users\mike\env\xxex3\ssds>python manage.py migrate
> Operations to perform:
> Synchronize unmigrated apps: admindocs, messages, credit, refer,
> company, workplace, staticfiles, substance, common
> Apply all migrations: contenttypes, sessions, auth, sites, admin
> Synchronizing apps without migrations:
> Creating tables...
> Running deferred SQL...
> Installing custom SQL...
> Running migrations:
> Rendering model states... DONE
> Applying contenttypes.0001_initial...Traceback (most recent call last):
> File
> "C:\Users\mike\env\xxex3\lib\site-packages\django\db\backends\utils.py",
> line 62, in execute
> return self.cursor.execute(sql)
> psycopg2.ProgrammingError: relation "django_content_type" already exists
>
>
> The above exception was the direct cause of the following exception:
>
> Traceback (most recent call last):
> File "manage.py", line 24, in <module>
> execute_from_command_line(sys.argv)
> File
> "C:\Users\mike\env\xxex3\lib\site-packages\django\core\management\__init__.py",
>
> line 338, in execute_from_command_line
> utility.execute()
> File
> "C:\Users\mike\env\xxex3\lib\site-packages\django\core\management\__init__.py",
>
> line 330, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
> File
> "C:\Users\mike\env\xxex3\lib\site-packages\django\core\management\base.py",
> line 390, in run_from_argv
> self.execute(*args, **cmd_options)
> File
> "C:\Users\mike\env\xxex3\lib\site-packages\django\core\management\base.py",
> line 441, in execute
> output = self.handle(*args, **options)
> File
> "C:\Users\mike\env\xxex3\lib\site-packages\django\core\management\commands\migrate.py",
>
> line 221, in handle
> executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
> File
> "C:\Users\mike\env\xxex3\lib\site-packages\django\db\migrations\executor.py",
>
> line 94, in migrate
> self.apply_migration(states[migration], migration, fake=fake,
> fake_initial=fake_initial)
> File
> "C:\Users\mike\env\xxex3\lib\site-packages\django\db\migrations\executor.py",
>
> line 131, in apply_migration
> state = migration.apply(state, schema_editor)
> File
> "C:\Users\mike\env\xxex3\lib\site-packages\django\db\migrations\migration.py",
>
> line 111, in apply
> operation.database_forwards(self.app_label, schema_editor,
> old_state, project_state)
>
> File
> "C:\Users\mike\env\xxex3\lib\site-packages\django\db\migrations\operations\models.py",
>
> line 59, in database_forwards
> schema_editor.create_model(model)
> File
> "C:\Users\mike\env\xxex3\lib\site-packages\django\db\backends\base\schema.py",
>
> line 282, in create_model
> self.execute(sql, params or None)
> File
> "C:\Users\mike\env\xxex3\lib\site-packages\django\db\backends\base\schema.py",
>
> line 107, in execute
> cursor.execute(sql, params)
> File
> "C:\Users\mike\env\xxex3\lib\site-packages\django\db\backends\utils.py",
> line 64, in execute
> return self.cursor.execute(sql, params)
> File "C:\Users\mike\env\xxex3\lib\site-packages\django\db\utils.py",
> line 97, in __exit__
> six.reraise(dj_exc_type, dj_exc_value, traceback)
> File "C:\Users\mike\env\xxex3\lib\site-packages\django\utils\six.py",
> line 658, in reraise
> raise value.with_traceback(tb)
> File
> "C:\Users\mike\env\xxex3\lib\site-packages\django\db\backends\utils.py",
> line 62, in execute
> return self.cursor.execute(sql)
> django.db.utils.ProgrammingError: relation "django_content_type" already
> exists
>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/551117F6.4010400%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment