Answer a question

I understand how many questions there are for this matter but none of the solutions suggested helped. I got the following problem: I deleted my models and deleted the imports in admin.py as well. Then I wanted to update the django database with makemigrations which shows that it deletes the model employee but then after using migrate command I saw an error that the relation does not exist. I also dropped it from the postgres database that I used. The strange thing here is that migrate keeps looking for the model which does not exists. Even if I create another one makemigrations detects it and then migrate says relation project_employee.. Tried syncdb --all no success. here is the output of migrate

Apply all migrations: sessions, project, admin, auth, contenttypes
Running migrations:
Applying project.0003_auto_20160318_1215...Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: relation "project_employee" does not exist


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

Traceback (most recent call last):
 File "manage.py", line 10, in <module>
  execute_from_command_line(sys.argv)
File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/usr/lib/python3/dist-packages/django/core/management/commands/migrate.py", line 161, in handle
executor.migrate(targets, plan, fake=options.get("fake", False))
File "/usr/lib/python3/dist-packages/django/db/migrations/executor.py", line 68, in migrate
self.apply_migration(migration, fake=fake)
File "/usr/lib/python3/dist-packages/django/db/migrations/executor.py", line 102, in apply_migration
migration.apply(project_state, schema_editor)
File "/usr/lib/python3/dist-packages/django/db/migrations/migration.py", line 108, in apply
operation.database_forwards(self.app_label, schema_editor, project_state, new_state)
 File "/usr/lib/python3/dist-packages/django/db/migrations/operations/fields.py", line 84, in database_forwards
schema_editor.remove_field(from_model, from_model._meta.get_field_by_name(self.name)[0])
 File "/usr/lib/python3/dist-packages/django/db/backends/schema.py", line 431, in remove_field
self.execute(sql)
 File "/usr/lib/python3/dist-packages/django/db/backends/schema.py", line 111, in execute
cursor.execute(sql, params)
 File "/usr/lib/python3/dist-packages/django/db/backends/utils.py", line 81, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
 File "/usr/lib/python3/dist-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
 File "/usr/lib/python3/dist-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
 File "/usr/lib/python3/dist-packages/django/utils/six.py", line 658, in reraise
raise value.with_traceback(tb)
 File "/usr/lib/python3/dist-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
 django.db.utils.ProgrammingError: relation "project_employee" does not exist

`

Thank you

Answers

What helped finally was deleting the whole migrations folder from the project's folder. Saw some south responses as well, but haven't tried.

Logo

学AI,认准AI Studio!GPU算力,限时免费领,邀请好友解锁更多惊喜福利 >>>

更多推荐