Developed in Visual Studio 2017. When performing "makemigrations", as well as checking for "manage.py check", I have the same system response:


Running: manage.py makemigrations

Traceback (most recent call last): File "...\DjangoWeb\env\lib\site-packages\django\db\backends\utils.py", line 64, in execute return self.cursor.execute(sql, params) File "...\DjangoWeb\env\lib\site-packages\django\db\backends\sqlite3\base.py", line 328, in execute return Database.Cursor.execute(self, query, params) sqlite3.OperationalError: no such table: app_entry The above exception was the direct cause of the following exception: Traceback (most recent call last): File "...\DjangoWeb\manage.py", line 17, in <module> execute_from_command_line(sys.argv) File "...\DjangoWeb\env\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line utility.execute() File "...\DjangoWeb\env\lib\site-packages\django\core\management\__init__.py", line 356, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "...\DjangoWeb\env\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv self.execute(*args, **cmd_options) File "...\DjangoWeb\env\lib\site-packages\django\core\management\base.py", line 327, in execute self.check() File "...\DjangoWeb\env\lib\site-packages\django\core\management\base.py", line 359, in check include_deployment_checks=include_deployment_checks, File "...\DjangoWeb\env\lib\site-packages\django\core\management\base.py", line 346, in _run_checks return checks.run_checks(**kwargs) File "...\DjangoWeb\env\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File "...\DjangoWeb\env\lib\site-packages\django\core\checks\urls.py", line 16, in check_url_config return check_resolver(resolver) File "...\DjangoWeb\env\lib\site-packages\django\core\checks\urls.py", line 26, in check_resolver return check_method() File "...\DjangoWeb\env\lib\site-packages\django\urls\resolvers.py", line 256, in check for pattern in self.url_patterns: File "...\DjangoWeb\env\lib\site-packages\django\utils\functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "...\DjangoWeb\env\lib\site-packages\django\urls\resolvers.py", line 407, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "...\DjangoWeb\env\lib\site-packages\django\utils\functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "...\DjangoWeb\env\lib\site-packages\django\urls\resolvers.py", line 400, in urlconf_module return import_module(self.urlconf_name) File "...\Microsoft Visual Studio\Shared\Python36_64\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File ".\DjangoWeb\urls.py", line 8, in <module> import app.views File ".\app\views.py", line 68, in <module> ENTRY_COUNT = Entry.objects.count() # кол-во зявок в БД File "...\DjangoWeb\env\lib\site-packages\django\db\models\manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "...\DjangoWeb\env\lib\site-packages\django\db\models\query.py", line 364, in count return self.query.get_count(using=self.db) File "...\DjangoWeb\env\lib\site-packages\django\db\models\sql\query.py", line 499, in get_count number = obj.get_aggregation(using, ['__count'])['__count'] File "...\DjangoWeb\env\lib\site-packages\django\db\models\sql\query.py", line 480, in get_aggregation result = compiler.execute_sql(SINGLE) File "...\DjangoWeb\env\lib\site-packages\django\db\models\sql\compiler.py", line 899, in execute_sql raise original_exception File "...\DjangoWeb\env\lib\site-packages\django\db\models\sql\compiler.py", line 889, in execute_sql cursor.execute(sql, params) File "...\DjangoWeb\env\lib\site-packages\django\db\backends\utils.py", line 79, in execute return super(CursorDebugWrapper, self).execute(sql, params) File "...\DjangoWeb\env\lib\site-packages\django\db\backends\utils.py", line 64, in execute return self.cursor.execute(sql, params) File "...\DjangoWeb\env\lib\site-packages\django\db\utils.py", line 94, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File ...\DjangoWeb\env\lib\site-packages\django\utils\six.py", line 685, in reraise raise value.with_traceback(tb) File "...\DjangoWeb\env\lib\site-packages\django\db\backends\utils.py", line 64, in execute return self.cursor.execute(sql, params) File "...\DjangoWeb\env\lib\site-packages\django\db\backends\sqlite3\base.py", line 328, in execute return Database.Cursor.execute(self, query, params) django.db.utils.OperationalError: no such table: app_entry 

At the same time, all migration files in the "migration" project folder are deleted, except for the file "--init--.py", and the database file itself is deleted and re-created by the system, but it constantly gives the above error ..

What can be wrong here and how to fix it?

  • Is this exactly a complete traceback? - andreymal
  • Added full Traceback .. - JBlack
  • How did it happen that you have the string ENTRY_COUNT = Entry.objects.count() in your views.py ? For some reason, are you accessing the database outside the view? - andreymal 2:38 pm
  • Exactly, it is. The global variable ENTRY_COUNT was created to get the number of all instances from the database in order to use its value in several views ... - JBlack
  • Well, in general, you can’t do that, take it away somewhere - andreymal

0