Upgrade von Django 1.6 auf 1.9: Fehler beim Migrieren von python manage.py
Ich verwende Django 1.6.6 in der Produktion und habe kürzlich ein Upgrade auf 1.9.7 in der Staging-Version (Dev-Server) durchgeführt. Dieses Update wurde auf dem Server durchgeführt und ich habe die hier beschriebenen Schritte ausgeführtUpgrade von South.
Ich habe festgestellt, dass sich die Struktur der Migrationsdateien geändert hat und sie kein @ mehr enthaltecreate
Erklärung. Dies führt zu Problemen, da wenn ich diesen neuen Code aus meinem GitHub-Repo ziehe undpython manage.py makemigrations
oderpython manage.py migrate
, es sagt
django.db.utils.OperationalError: no such table: appname_modelname
Der Traceback verweist auf meine urls.py, da ich das Modell in einem Abfragesatz referenziere:
queryset=list(chain(models.modelname.objects.filter(booleanField=True).order_by(object), models.aDifferentModel.objects.all())),
Vor dem Upgrade auf 1.9,syncdb
hat die Tabellen für mich erstellt, aber das ist bei @ nicht der Famigrate
. Ich habe es auch versuchtpython manage.py migrate --run-syncdb
aber das gibt den gleichen Fehler.
Wenn ich jedoch die SQLite-Datenbank aus meiner Produktions- oder Staging-Umgebung auf meinen lokalen Computer kopiere und den Befehl ausführe, funktioniert dies (da sich die Tabelle bereits in der Datenbank befindet).
Muss ich diese Tabellen manuell erstellen (obwohl ich das nicht annehme) oder mache ich etwas falsch?
Edit: Code-Snippets und Tracebacks hinzugefügt. Entschuldigen Sie, dass Sie dies zunächst nicht getan haben.
models.py
class HowToApply(models.Model):
title = models.CharField(max_length=500, blank=True, null=True)
notice = models.TextField(blank=True, null=True)
description = models.TextField(blank=True, null=True)
active = models.BooleanField(default=None)
image = models.FileField(upload_to='numeric/img/%Y', blank=True, null=True)
mobile_image = models.FileField(upload_to='mobile/img/%Y', blank=True, null=True)
sequence_number = models.IntegerField(unique=True)
...
urls.py
from django.conf.urls import patterns, include, url
from django.views.generic import RedirectView, TemplateView, ListView, CreateView
from numeric import models, forms, views
from honeypot.decorators import check_honeypot
from numeric.views import CheckDeviceView
from itertools import chain
urlpatterns = patterns('',
url(r'^academy/howtoapply/ ...
zurück verfolge
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
utility.execute()
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 342, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 398, in execute
self.check()
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 426, in check
include_deployment_checks=include_deployment_checks,
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/core/checks/registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 10, in check_url_config
return check_resolver(resolver)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 19, in check_resolver
for pattern in resolver.url_patterns:
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 417, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 410, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/var/www/website_mig/project/urls.py", line 14, in <module>
(r'^', include('numeric.urls')),
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 52, in include
urlconf_module = import_module(urlconf_module)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/var/www/website_mig/numeric/urls.py", line 144, in <module>
queryset = list(chain(models.HowToApply.objects.filter(active=True).order_by('sequence_number'), models.AcademyAdmin.objects.all())),
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/db/models/query.py", line 258, in __iter__
self._fetch_all()
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/db/models/query.py", line 1074, in _fetch_all
self._result_cache = list(self.iterator())
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/db/models/query.py", line 52, in __iter__
results = compiler.execute_sql()
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 852, in execute_sql
cursor.execute(sql, params)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/db/utils.py", line 95, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 323, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: numeric_howtoapply`
,
ListView.as_view(
queryset = list(chain(models.HowToApply.objects.filter(active=True).order_by('sequence_number'), models.AcademyAdmin.objects.all())),
template_name = 'numeric/apply.html'
),
name='apply'),
...
zurück verfolge
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
utility.execute()
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 342, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 398, in execute
self.check()
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 426, in check
include_deployment_checks=include_deployment_checks,
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/core/checks/registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 10, in check_url_config
return check_resolver(resolver)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 19, in check_resolver
for pattern in resolver.url_patterns:
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 417, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 410, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/var/www/website_mig/project/urls.py", line 14, in <module>
(r'^', include('numeric.urls')),
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 52, in include
urlconf_module = import_module(urlconf_module)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/var/www/website_mig/numeric/urls.py", line 144, in <module>
queryset = list(chain(models.HowToApply.objects.filter(active=True).order_by('sequence_number'), models.AcademyAdmin.objects.all())),
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/db/models/query.py", line 258, in __iter__
self._fetch_all()
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/db/models/query.py", line 1074, in _fetch_all
self._result_cache = list(self.iterator())
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/db/models/query.py", line 52, in __iter__
results = compiler.execute_sql()
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 852, in execute_sql
cursor.execute(sql, params)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/db/utils.py", line 95, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/var/www/website_mig/venv/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 323, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: numeric_howtoapply`