ich nicht in der Lage bin makemigrations
zu laufen, migrate
, oder irgendetwas anderes (flush
, reset_db
von django-Erweiterungen), wenn ich eine bestimmte App in meinem INSTALLED_APPS habe .Django - nicht makemigrations ausführen: „keine solche Tabelle“ auch nach reset_db läuft
Die App ist issues
genannt und hat ein Modell:
class Issue(models.Model):
title = models.CharField(max_length=255)
description = models.CharField(max_length=1000)
sent = models.BooleanField()
Und es funktioniert vor (makemigrations und Migration lief gut und ich konnte das app/Modell richtig verwenden), bis ich das Hinzufügen versucht:
severity = models.IntegerField()
und versucht, Makemigrationen auszuführen. Ich habe den Fehler nicht mehr oder erinnere mich nicht mehr, aber seitdem ist alles kaputt, selbst nachdem ich severity
aus dem Modell entfernt habe.
Alles funktioniert, wenn ich die issues
App aus meinem settings.py entferne.
Der Fehler erhalte ich:
[email protected]:~/workspace/budget/src$ python3.5 manage.py makemigrationsTraceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python3.5/dist-packages/django/db/backends/sqlite3/base.py", line 337, in execute
return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such table: issues_issue
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 341, in execute
django.setup()
File "/usr/local/lib/python3.5/dist-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python3.5/dist-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/home/madjura/workspace/budget/src/issues/apps.py", line 16, in ready
issues.models.Issue.objects.check_and_send_unsent_issues()
File "/home/madjura/workspace/budget/src/issues/models.py", line 18, in check_and_send_unsent_issues
for issue in issues:
File "/usr/local/lib/python3.5/dist-packages/django/db/models/query.py", line 256, in __iter__
self._fetch_all()
File "/usr/local/lib/python3.5/dist-packages/django/db/models/query.py", line 1087, in _fetch_all
self._result_cache = list(self.iterator())
File "/usr/local/lib/python3.5/dist-packages/django/db/models/query.py", line 54, in __iter__
results = compiler.execute_sql()
File "/usr/local/lib/python3.5/dist-packages/django/db/models/sql/compiler.py", line 835, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python3.5/dist-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python3.5/dist-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python3.5/dist-packages/django/db/backends/sqlite3/base.py", line 337, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: issues_issue
Während Probleme in INSTALLED_APPS ist ich den gleichen Fehler, wenn Migrate läuft, bündig und reset_db.
Ich habe versucht, flush und reset_db mit Problemen aus INSTALLED_APPS entfernt, löste das Problem nicht.
Ich habe versucht, die oben genannten und dann läuft Makemigrationen und migrieren, das funktioniert auch nicht. Sobald ich Probleme in INSTALLED_APPS zurückgebe, ist alles kaputt.
Wie kann ich das beheben?
EDIT:
Vielleicht relevant, das Problem Modell einen Manager mit einer Funktion hat:
class IssueManager(models.Manager):
"""Manager for the Issue class."""
def check_and_send_unsent_issues(self):
"""
Checks for unsent Issue objects (Issue.sent = False) and attempts
to send them.
Issues that have been sent are deleted.
If the issue fails to be sent for whatever reason, it is not deleted.
Does nothing if there are no unsent issues.
This method is called once when the server starts.
"""
issues = self.get_queryset().filter(sent=False)
for issue in issues:
try:
make_issue(issue.title, issue.description)
issue.delete()
except PostIssueException:
pass
Mit apps.py ich für nicht gesendete Fragen überprüfen und sie auf Gitlab.
EDIT 2:
aufgelöst Ausgabe durch die Linie, unterhalb der Kommentierung erscheint in meinem apps.py
, in ready()
:
issues.models.Issue.objects.check_and_send_unsent_issues()
die irgendwie Dinge verursacht zu brechen, verstehe ich nicht, warum. Könnte jemand das bitte erklären?