Monday, May 30, 2016

Re: ProgrammingError: relation "django_content_type" already exists

Thanks Tim! Running manage.py migrate --fake-initial solved the problem!

Am Freitag, 10. April 2015 02:40:56 UTC+2 schrieb Tim Graham:
Hi Mike,

Take a look at the migrate --fake-initial option. It's new in 1.8. In 1.7, --fake-initial was an implicit default, but we decided to make it explicit in 1.8.

https://docs.djangoproject.com/en/1.8/ref/django-admin/#django-admin-option---fake-initial

On Thursday, April 9, 2015 at 7:05:43 PM UTC-4, Mike Dewhirst wrote:
Nik

See also my 6 April "KeyError: 'default'" thread
https://groups.google.com/forum/#!topic/django-users/U9y9_EeVyPE

It also involves contenttypes ...

> Creating test database for alias 'default'...
> Traceback (most recent call last):
>    File
> "C:\Users\mike\env\xxex3\lib\site-packages\django\contrib\contenttypes\models.py",
> line 19, in get_by_natural_key
>      ct = self.__class__._cache[self.db][(app_label, model)]
> KeyError: 'default'

No luck there either.

Mike

On 10/04/2015 8:43 AM, Mike Dewhirst wrote:
> Nik
>
> Unfortunately no luck here. I'm staying with 1.6 until I can find the
> time to establish a suite of dev sites each with their own database.
>
> And I expect (now) that I'll go via 1.7 to 1.8.
>
> I have been half hoping that someone else would discover the answer and
> share it. If I solve it I'll certainly do that.
>
> It is high on my todo list because it has to be done before the next
> point release - which will omit 1.6.
>
> Good luck
>
> Mike
>
> On 10/04/2015 3:41 AM, manikos wrote:
>> Hello Mike.
>>
>> Today I took the road to upgrade from Django 1.6 --> 1.8. I wanted the
>> bugfixes support and the long-term.
>> Everything looked good at the very beginning BUT it turned out that I
>> get the same error with you, concerning the "django_content_type"
>> already exists.
>> Have you found a solution to the problem?
>>
>> Looking for your reply,
>> best regards,
>> nik
>>
>> On Tuesday, March 24, 2015 at 8:00:28 AM UTC+2, 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 <http://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...@googlegroups.com
>> <mailto:django-users+unsubscribe@googlegroups.com>.
>> To post to this group, send email to django...@googlegroups.com
>> <mailto:django...@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/33a00654-229e-41eb-a2b4-88dfdbd08396%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/django-users/33a00654-229e-41eb-a2b4-88dfdbd08396%40googlegroups.com?utm_medium=email&utm_source=footer>.
>>
>> For more options, visit https://groups.google.com/d/optout.
>

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/528b62ad-4e0c-493d-8edb-c01156e6c23a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment