Попробуйте Django class 21 - .get ()

Выполняя попытку Django из кода для предпринимателей, у меня возникли проблемы с классом 21. В начале класса он просит ввести файл produc.objects.get (id = 1), чтобы получить объекты класса, но я У меня есть ошибка в моей Shell, и я не могу определить, что это такое. Я скопировал ошибку.

obj = product.objects.get(id=1)

> Traceback (most recent call last):
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 296, in execute
    return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such table: products_product

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/models/query.py", line 393, in get
    num = len(clone)
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/models/query.py", line 250, in __len__
    self._fetch_all()
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/models/query.py", line 1183, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/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 "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1061, in execute_sql
    cursor.execute(sql, params)
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
    return super().execute(sql, params)
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 296, in execute
    return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: products_product

python,django,

0

Ответов: 0

Попробуйте Django class 21 - .get ()

Выполняя попытку Django из кода для предпринимателей, у меня возникли проблемы с классом 21. В начале класса он просит ввести файл produc.objects.get (id = 1), чтобы получить объекты класса, но я У меня есть ошибка в моей Shell, и я не могу определить, что это такое. Я скопировал ошибку.

obj = product.objects.get(id=1)

> Traceback (most recent call last):
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 296, in execute
    return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such table: products_product

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/models/query.py", line 393, in get
    num = len(clone)
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/models/query.py", line 250, in __len__
    self._fetch_all()
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/models/query.py", line 1183, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/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 "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1061, in execute_sql
    cursor.execute(sql, params)
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
    return super().execute(sql, params)
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/Users/pedrosantos/.local/share/virtualenvs/try_django-xpD0_Dxa/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 296, in execute
    return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: products_product
00питон, Джанго,
Похожие вопросы
Яндекс.Метрика