Answer the question
In order to leave comments, you need to log in
Why can't PostgreSQL see the column?
Django 2
when trying to save to a query variable, the query throws this error
>>> query = Post.objects.create(title='Блюдо1', slug='Здесь рецепт и описание', category='category', cost='Цена')
Traceback (most recent call last):
File "<input>", line 1, in <module>
query = Post.objects.create(title='Блюдо1', slug='Здесь рецепт и описание', category='category', cost='Цена')
File "/home/ivan/.local/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/ivan/.local/lib/python3.6/site-packages/django/db/models/query.py", line 413, in create
obj.save(force_insert=True, using=self.db)
File "/home/ivan/.local/lib/python3.6/site-packages/django/db/models/base.py", line 718, in save
force_update=force_update, update_fields=update_fields)
File "/home/ivan/.local/lib/python3.6/site-packages/django/db/models/base.py", line 748, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/home/ivan/.local/lib/python3.6/site-packages/django/db/models/base.py", line 831, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/home/ivan/.local/lib/python3.6/site-packages/django/db/models/base.py", line 869, in _do_insert
using=using, raw=raw)
File "/home/ivan/.local/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/ivan/.local/lib/python3.6/site-packages/django/db/models/query.py", line 1136, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "/home/ivan/.local/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1289, in execute_sql
cursor.execute(sql, params)
File "/home/ivan/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
return super().execute(sql, params)
File "/home/ivan/.local/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 "/home/ivan/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/ivan/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/home/ivan/.local/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/ivan/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: ОШИБКА: столбец "category" в таблице "tst_post" не существует
LINE 1: INSERT INTO "tst_post" ("title", "slug", "category", "cost")...
from django.db import models
class Post(models.Model):
title = models.CharField(max_length=30, db_index=True)
slug = models.SlugField(max_length=150, unique=True)
category = models.TextField(blank=True, db_index=True)
cost = models.TextField(max_length=9, db_index=True)
def __str__(self):
return '{}'.format(self.tit
Answer the question
In order to leave comments, you need to log in
Maybe they accidentally started writing category with Russian “s”?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question