Saturday, November 30, 2019

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

Hi Integr,

Thank you for your email.

Your mean these steps have to be run again?

4. 'loaddata'command in virtualenv to load the data to Postgress.
5. ~/vkproject/manage.py makemigrations
6. ~/vkproject/manage.py migrate

~Ram

On Sat, Nov 30, 2019 at 11:28 AM Integr@te System <datacentralize@gmail.com> wrote:
Hi issuer,

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

On Sun, Dec 1, 2019, 00:03 Ram <ram.mullapudi@gmail.com> wrote:
 Hi,

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/manage.py makemigrations
    No changes detected
    (vkenv) shami@ubuntu-wed-01~$ ~/vkproject/manage.py 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/utils.py", 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/manage.py", line 21, in <module>
        main()
      File "/home/shami/vkproject/manage.py", line 17, in main
        execute_from_command_line(sys.argv)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
        utility.execute()
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
        self.execute(*args, **cmd_options)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute
        output = self.handle(*args, **options)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/core/management/base.py", line 83, in wrapped
        res = handle_func(*args, **kwargs)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 234, in handle
        fake_initial=fake_initial,
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/db/migrations/executor.py", 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/executor.py", 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/executor.py", line 245, in apply_migration
        state = migration.apply(state, schema_editor)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/db/migrations/migration.py", 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/models.py", line 92, in database_forwards
        schema_editor.create_model(model)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/db/backends/base/schema.py", 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/schema.py", line 137, in execute
        cursor.execute(sql, params)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 99, in execute
        return super().execute(sql, params)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/db/backends/utils.py", 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/utils.py", 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/utils.py", line 84, in _execute
        return self.cursor.execute(sql, params)
      File "/home/shami/vkproject/vkenv/lib/python3.6/site-packages/django/db/utils.py", 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/utils.py", 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/manage.py 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/manage.py --version      2.2.7

I appreciate if someone can provide a clue here.

Thanks in advance,

~Ram

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BOi5F2GuoQAaiDY_cWzemddpKhrjwWixJMmdyrDRJoT98zs_w%40mail.gmail.com.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAP5HUWqak322yfhhmbFapEZ9VWH-NBTGLyTqq4KS2oQf%2BFHqjA%40mail.gmail.com.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BOi5F2qDKBZUbXBh5qrPe%2BQ1vwWCVuXbE_JAxhN6%3DKePBdbvg%40mail.gmail.com.

No comments:

Post a Comment