私は大規模なプロジェクトにdjango 1.3とPython 2.4を使用していました。私はこれをdjango 1.9とpython 2.7にアップデートすることにしました。django_adminデータベース作成、SQLの値下げ後
django_adminのsqlパラメータが1.9で犠牲になるため、データベースの更新方法が大きく変更されました。
私はコマンドを使用しています:
python /usr/local/django/<project>/manage.py migrate --fake-initial --noinput --run-syncdb
表作成のために。しかし、私のテーブルは作成されず、このエラーが表示されます。
Traceback (most recent call last):
File "/src/project/project-export/django/projectadmin/manage.py", line 13, in <module>
execute_from_command_line(sys.argv)
File "/opt/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/opt/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/python/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/opt/python/lib/python2.7/site-packages/django/core/management/base.py", line 398, in execute
self.check()
File "/opt/python/lib/python2.7/site-packages/django/core/management/base.py", line 426, in check
include_deployment_checks=include_deployment_checks,
File "/opt/python/lib/python2.7/site-packages/django/core/checks/registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "/opt/python/lib/python2.7/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/opt/python/lib/python2.7/site-packages/django/core/checks/urls.py", line 23, in check_resolver
for pattern in resolver.url_patterns:
File "/opt/python/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/opt/python/lib/python2.7/site-packages/django/core/urlresolvers.py", line 417, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/opt/python/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/opt/python/lib/python2.7/site-packages/django/core/urlresolvers.py", line 410, in urlconf_module
return import_module(self.urlconf_name)
File "/opt/python/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/usr/local/django/projectadmin/projectadmin/urls.py", line 4, in <module>
import projectadmin.views
File "/usr/local/django/projectadmin/projectadmin/views.py", line 20, in <module>
from projectadmin.forms import UserCreationForm
File "/usr/local/django/projectadmin/projectadmin/forms.py", line 252, in <module>
class UserCreationForm(forms.ModelForm):
File "/usr/local/django/projectadmin/projectadmin/forms.py", line 256, in UserCreationForm
template_choice = form_utils.create_template_choices_field()
File "/usr/local/django/projectadmin/projectadmin/form_utils.py", line 15, in create_template_choices_field
choices = [(x.id, x.template_name) for x in all_templates]
File "/opt/python/lib/python2.7/site-packages/django/db/models/query.py", line 258, in __iter__
self._fetch_all()
File "/opt/python/lib/python2.7/site-packages/django/db/models/query.py", line 1074, in _fetch_all
self._result_cache = list(self.iterator())
File "/opt/python/lib/python2.7/site-packages/django/db/models/query.py", line 52, in __iter__
results = compiler.execute_sql()
File "/opt/python/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 848, in execute_sql
cursor.execute(sql, params)
File "/opt/python/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/opt/python/lib/python2.7/site-packages/django/db/utils.py", line 95, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/opt/python/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/opt/python/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 112, in execute
return self.cursor.execute(query, args)
File "/opt/python/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
self.errorhandler(self, exc, value)
File "/opt/python/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
django.db.utils.ProgrammingError: (1146, "Table 'project.projectadmin_usertemplate' doesn't exist")
エラーでテーブルの作成に関連するものはありません。それはテーブルが欠落していると文句を言うが、テーブルを作成しない。
INSTALLED_APPS
にテーブルが含まれていないと思われますが、settings.py
のリストに自分のアプリケーションを追加しました。 installed_apps
のリストに自分のアプリケーションを別に追加する必要があることに疑念が沸きました。
システムのアップデート中にdjango自身が推奨する手順に従っています。
私の疑惑が真実なら、インストールされたアプリにモデルを追加するにはどうすればいいですか?
'python manage.py migrate'を実行する前に' python manage.py makemigrations'を実行しましたか? – hulkinBrain
@hulkinBrainはい私はそれを試みたが、同じ問題がまだあります。 – yalinaksoy
エラーログをアップロードできますか? – hulkinBrain