У Django нет такой таблицы: django_site после удаления миграций и базы данных - PullRequest
0 голосов
/ 22 марта 2019

Я пытался изменить имя приложения.Это не сработало, и поэтому я попытался изменить его обратно.Это тоже не сработало, и я удалил все миграции и мой 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

Я пробовал эти ответы, но они не помогли мне: Нет такой таблицы, как django_site , Django 1.5.4: такой таблицы нет: django_site в admin /

Я действительно не знаю, что делать.Может быть, кто-то может мне помочь.

1 Ответ

1 голос
/ 22 марта 2019

удалить 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

Это должно сделать это.

...