Saturday, November 30, 2019

Re: django.db.utils.ProgrammingError: relation "django_content_type" already exists

Hi issuer,

You do step 4 and step 5 with the same goal!?

On Sun, Dec 1, 2019, 00:03 Ram <> wrote:

I'm blocked with this issue in my newly hosting site. Here is my scenario.

  1. I've working site with MySQL database in our development localhost.
  2. I created new hosting server in Digital Ocean's Ubuntu 18.04 droplet with Postgres db.
  3. I tested the server with empty database and empty Django site when I build this hosting server.
  4. I manually migrated MySQL database to Postgres using pgAdmin tool and ran 'loaddata'command in virtualenv to load the data to Postgress.
  5. Now when I ran the following commands I see the same issue as reported here.

  6. (vkenv) shami@ubuntu-wed-01:~$ ~/vkproject/ makemigrations
    No changes detected
    (vkenv) shami@ubuntu-wed-01~$ ~/vkproject/ migrate
    Operations to perform:
      Apply all migrations: admin, auth, contenttypes, pages, sessions
    Running migrations:
      Applying contenttypes.0001_initial...Traceback (most recent call last):
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/db/backends/", line 82, in _execute
        return self.cursor.execute(sql)
    psycopg2.errors.DuplicateTable: relation "django_content_type" already exists

    The above exception was the direct cause of the following exception:

    Traceback (most recent call last):
      File "/home/shami/vkproject/", line 21, in <module>
      File "/home/shami/vkproject/", line 17, in main
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/core/management/", line 381, in execute_from_command_line
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/core/management/", line 375, in execute
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/core/management/", line 323, in run_from_argv
        self.execute(*args, **cmd_options)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/core/management/", line 364, in execute
        output = self.handle(*args, **options)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/core/management/", line 83, in wrapped
        res = handle_func(*args, **kwargs)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/core/management/commands/", line 234, in handle
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/db/migrations/", line 117, in migrate
        state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/db/migrations/", line 147, in _migrate_all_forwards
        state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/db/migrations/", line 245, in apply_migration
        state = migration.apply(state, schema_editor)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/db/migrations/", line 124, in apply
        operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/db/migrations/operations/", line 92, in database_forwards
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/db/backends/base/", line 307, in create_model
        self.execute(sql, params or None)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/db/backends/base/", line 137, in execute
        cursor.execute(sql, params)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/db/backends/", line 99, in execute
        return super().execute(sql, params)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/db/backends/", line 67, in execute
        return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/db/backends/", line 76, in _execute_with_wrappers
        return executor(sql, params, many, context)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/db/backends/", line 84, in _execute
        return self.cursor.execute(sql, params)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/db/", line 89, in __exit__
        raise dj_exc_value.with_traceback(traceback) from exc_value
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/db/backends/", line 82, in _execute
        return self.cursor.execute(sql)
    django.db.utils.ProgrammingError: relation "django_content_type" already exists

  7.     (vkenv) shami@ubuntu-wed-01:~$ ~/vkproject/ showmigrations      admin       [ ] 0001_initial       [ ] 0002_logentry_remove_auto_add       [ ] 0003_logentry_add_action_flag_choices      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       [ ] 0007_alter_validators_add_error_messages       [ ] 0008_alter_user_username_max_length       [ ] 0009_alter_user_last_name_max_length       [ ] 0010_alter_group_name_max_length       [ ] 0011_update_proxy_permissions      contenttypes       [ ] 0001_initial       [ ] 0002_remove_content_type_name      pages       [ ] 0001_initial       [ ] 0002_auto_20190504_1638       [ ] 0003_auto_20190504_1645       [ ] 0004_auto_20190504_1651       [ ] 0005_auto_20190506_1451       [ ] 0006_auto_20190506_1558       [ ] 0007_auto_20190506_1803       [ ] 0008_auto_20190508_1455       [ ] 0009_auto_20190508_1554       [ ] 0010_rim_banners       [ ] 0011_rim_banners_link_id       [ ] 0012_auto_20190520_1137       [ ] 0013_auto_20190520_1144       [ ] 0014_rim_transactions_cj       [ ] 0015_auto_20190617_1756       [ ] 0016_auto_20190619_1433       [ ] 0017_rim_cj_feed      sessions       [ ] 0001_initial      (vkenv) shami@ubuntu-wed-01:~$ 
                  (vkenv) shami@ubuntu-wed-01:~$ ~/vkproject/ --version      2.2.7

I appreciate if someone can provide a clue here.

Thanks in advance,


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
To view this discussion on the web visit

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
To view this discussion on the web visit

No comments:

Post a Comment