我试图更改应用名称。这没有用,所以我试图改回去。这也不起作用,我删除了所有迁移和db.sqlite。现在,每当我尝试makemigrations
或migrate
时,都会出现此错误:
django.db.utils.OperationalError: no such table: django_site
完整追溯:
Traceback (most recent call last):
File "C:\Users\Myzel394\Documents\PROGRAMMIEREN\Schule\MGLZeitung\manage.py", line 18, in <module>
execute_from_command_line(sys.argv)
File "C:\Program Files\Python37\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Program Files\Python37\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Program Files\Python37\lib\site-packages\django\core\management\base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Program Files\Python37\lib\site-packages\django\core\management\base.py", line 350, in execute
self.check()
File "C:\Program Files\Python37\lib\site-packages\django\core\management\base.py", line 379, in check
include_deployment_checks=include_deployment_checks,
File "C:\Program Files\Python37\lib\site-packages\django\core\management\base.py", line 366, in _run_checks
return checks.run_checks(**kwargs)
File "C:\Program Files\Python37\lib\site-packages\django\core\checks\registry.py", line 71, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Program Files\Python37\lib\site-packages\django\core\checks\urls.py", line 40, in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
File "C:\Program Files\Python37\lib\site-packages\django\core\checks\urls.py", line 57, in _load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
File "C:\Program Files\Python37\lib\site-packages\django\utils\functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Program Files\Python37\lib\site-packages\django\urls\resolvers.py", line 533, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Program Files\Python37\lib\site-packages\django\utils\functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Program Files\Python37\lib\site-packages\django\urls\resolvers.py", line 526, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Program Files\Python37\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\Myzel394\Documents\PROGRAMMIEREN\Schule\MGLZeitung\MGLZeitung\urls.py", line 28, in <module>
path('account/', include("apps.account.urls", namespace="account")),
File "C:\Program Files\Python37\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Program Files\Python37\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\Myzel394\Documents\PROGRAMMIEREN\Schule\MGLZeitung\apps\account\urls.py", line 15, in <module>
path('loeschen/fertig', TemplateView.as_view(template_name="account/account/delete_done.html", extra_context={'title': title_suffix("Account Gelöscht")}), name="delete_done")
File "C:\Users\Myzel394\Documents\PROGRAMMIEREN\Schule\MGLZeitung\utils\urls.py", line 12, in title_suffix
return URL_SUFFIX_ONE.format(title, " ".join(site_name()))
File "C:\Users\Myzel394\Documents\PROGRAMMIEREN\Schule\MGLZeitung\apps\homepage\templatetags\utils.py", line 219, in site_name
return Site.objects.all().first().name.split(" ")
File "C:\Program Files\Python37\lib\site-packages\django\db\models\query.py", line 605, in first
for obj in (self if self.ordered else self.order_by('pk'))[:1]:
File "C:\Program Files\Python37\lib\site-packages\django\db\models\query.py", line 268, in __iter__
self._fetch_all()
File "C:\Program Files\Python37\lib\site-packages\django\db\models\query.py", line 1186, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "C:\Program Files\Python37\lib\site-packages\django\db\models\query.py", line 54, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "C:\Program Files\Python37\lib\site-packages\django\db\models\sql\compiler.py", line 1065, in execute_sql
cursor.execute(sql, params)
File "C:\Program Files\Python37\lib\site-packages\django\db\backends\utils.py", line 100, in execute
return super().execute(sql, params)
File "C:\Program Files\Python37\lib\site-packages\django\db\backends\utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "C:\Program Files\Python37\lib\site-packages\django\db\backends\utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "C:\Program Files\Python37\lib\site-packages\django\db\backends\utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "C:\Program Files\Python37\lib\site-packages\django\db\utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "C:\Program Files\Python37\lib\site-packages\django\db\backends\utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "C:\Program Files\Python37\lib\site-packages\django\db\backends\sqlite3\base.py", line 298, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: django_site
我尝试了以下答案,但它们并没有帮助我:No such table as django_site,Django 1.5.4: no such table: django_site in admin/
我真的不知道该怎么办。也许有人可以帮助我。
答案 0 :(得分:1)
从django.contrib.sites
中的installed_apps
中删除settings.py
然后运行:
python manage.py makemigrations
python manage.py migrate
将django.contrib.sites
添加到您的installed_apps
并运行:
python manage.py makemigrations
python manage.py migrate
应该这样做。