2020-12-08 18:58

Can't seem to run ./manage.py migrate successfully. I'm getting a programmingerror with shop.0007_Notification_recipient

Hi there, I'm having a hard time resolving the migrate issue. I have initially changed all the smart card and smartphone models to caps and t-shirts respectively but when I migrate so it shows what I've changed it's giving me a programmingerror behind the shop.0007_notification_recipient as it already exists. I've tried with some suggested resolves from issues section but I'm getting nowhere.

My traceback is as follows:

python manage.py migrate c:\users\kaukau\anacondaprojects\django_projects\web_project00h\nuttyhoggz_var8\django-shop\shop\admin\product.py:109: UserWarning: Your caching backend does not support deletion by key patterns. Please use 'django-redis-cache', or wait until the product's HTML snippet cache expires by itself. warnings.warn("\n" Operations to perform: Apply all migrations: admin, auth, authtoken, cms, cmsplugin_cascade, contenttypes, djangocms_text_ckeditor, easy_thumbnails, email_auth, filer, menus, myshop, post_office, sessions, shop, sites Running migrations: Applying shop.0007_notification_recipient...Traceback (most recent call last): File "C:\Users\kaukau\Anaconda3\envs\ENV_NH_var8\lib\site-packages\django\db\backends\utils.py", line 64, in execute return self.cursor.execute(sql, params) psycopg2.ProgrammingError: column "notify" of relation "shop_notification" already exists

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

Traceback (most recent call last): File "manage.py", line 10, in execute_from_command_line(sys.argv) File "C:\Users\kaukau\Anaconda3\envs\ENV_NH_var8\lib\site-packages\django\core\management__init__.py", line 364, in execute_from_command_line utility.execute() File "C:\Users\kaukau\Anaconda3\envs\ENV_NH_var8\lib\site-packages\django\core\management__init__.py", line 356, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Users\kaukau\Anaconda3\envs\ENV_NH_var8\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv self.execute(args, cmd_options) File "C:\Users\kaukau\Anaconda3\envs\ENV_NH_var8\lib\site-packages\django\core\management\base.py", line 330, in execute output = self.handle(args, **options) File "C:\Users\kaukau\Anaconda3\envs\ENV_NH_var8\lib\site-packages\django\core\management\commands\migrate.py", line 204, in handle fake_initial=fake_initial, File "C:\Users\kaukau\Anaconda3\envs\ENV_NH_var8\lib\site-packages\django\db\migrations\executor.py", line 115, in migrate state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File "C:\Users\kaukau\Anaconda3\envs\ENV_NH_var8\lib\site-packages\django\db\migrations\executor.py", line 145, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "C:\Users\kaukau\Anaconda3\envs\ENV_NH_var8\lib\site-packages\django\db\migrations\executor.py", line 244, in apply_migration state = migration.apply(state, schema_editor) File "C:\Users\kaukau\Anaconda3\envs\ENV_NH_var8\lib\site-packages\django\db\migrations\migration.py", line 129, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "C:\Users\kaukau\Anaconda3\envs\ENV_NH_var8\lib\site-packages\django\db\migrations\operations\fields.py", line 88, in database_forwards field, File "C:\Users\kaukau\Anaconda3\envs\ENV_NH_var8\lib\site-packages\django\db\backends\base\schema.py", line 445, in add_field self.execute(sql, params) File "C:\Users\kaukau\Anaconda3\envs\ENV_NH_var8\lib\site-packages\django\db\backends\base\schema.py", line 136, in execute cursor.execute(sql, params) File "C:\Users\kaukau\Anaconda3\envs\ENV_NH_var8\lib\site-packages\django\db\backends\utils.py", line 79, in execute return super(CursorDebugWrapper, self).execute(sql, params) File "C:\Users\kaukau\Anaconda3\envs\ENV_NH_var8\lib\site-packages\django\db\backends\utils.py", line 64, in execute return self.cursor.execute(sql, params) File "C:\Users\kaukau\Anaconda3\envs\ENV_NH_var8\lib\site-packages\django\db\utils.py", line 94, in exit six.reraise(dj_exc_type, dj_exc_value, traceback) File "C:\Users\kaukau\Anaconda3\envs\ENV_NH_var8\lib\site-packages\django\utils\six.py", line 685, in reraise raise value.with_traceback(tb) File "C:\Users\kaukau\Anaconda3\envs\ENV_NH_var8\lib\site-packages\django\db\backends\utils.py", line 64, in execute return self.cursor.execute(sql, params) django.db.utils.ProgrammingError: column "notify" of relation "shop_notification" already exists

Where am I going wrong. Please help.


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • weixin_39834488 weixin_39834488 5月前

    Then you have a mismatch between the entries in table django_migrations and your current state of table schema. Try to migrate to the next step, ie. 0008 using ./manage.py migrate shop 0008 --fake.

    点赞 评论 复制链接分享
  • weixin_39759881 weixin_39759881 5月前

    Alright let me try that. And I somewhat deleted the 0007 py file to see what happens but now as I run the server I'm going direct to the admin page.. I'm assuming the command you instructed me to run will allow my changes to the models show right?

    点赞 评论 复制链接分享
  • weixin_39759881 weixin_39759881 5月前

    Hi Sir, I ran the command and it worked with no error... But I'm getting redirected to the django admin page and not home. I only changed the variables of smartphone to tshirts and smartcard to caps as I chose i18n_polymorphic and changed manufacturer to Brand aswell as the template files matching the changes in the models, urls were also edited but now it seems everything is broken. I'm still new to django but I know if the models are edited then one should perform the migrations so that when you run the server the changes show. Is it possible to restart the whole thing and make the changes before I initially migrate or this can be fixed. Please let me know if you can help me out with. Thank you

    点赞 评论 复制链接分享
  • weixin_39668571 weixin_39668571 5月前

    did you rename your variables after you completed the tutorial?

    Drop the database (if it is sqlite, just delete the file or open PGAdmin and drop databasse) and start anew.
    Run the tutorial first and set up the database completely. Try to check if it is running first. Then rename your varialbes. Then run ./manage.py makemigrations Then run ./manage.py migrate

    点赞 评论 复制链接分享