Answer the question
In order to leave comments, you need to log in
Why it is impossible to address from this part of request?
I use psycopg2
joxi.ru/LmGeRznSweYqbA -
database query table -
curr.execute("INSERT INTO public.instagram_post VALUES (post_id,link,image,like_count,comment,comment_count,login_id)",
[id,link,photo,comment,comment_count,account[1]])
psycopg2.ProgrammingError: ОШИБКА: столбец "post_id" не существует
LINE 1: INSERT INTO public.instagram_post VALUES (post_id,link,image...
^
HINT: Столбец "post_id" есть в таблице "instagram_post", но на него нельзя ссылаться из этой части запроса.
class Post(models.Model):
login = models.ForeignKey(Instagram, on_delete=models.CASCADE)
post_id = models.PositiveIntegerField(primary_key=True)
link = models.CharField(max_length=300)
image = models.CharField(max_length=300)
like_count = models.PositiveIntegerField(default=0)
comment = models.CharField(max_length=1500, blank=True)
comment_count = models.PositiveIntegerField(default=0)
Answer the question
In order to leave comments, you need to log in
You can use the ORM and django models anywhere in this way:
import os
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings") # путь к файлу настроек
django.setup()
project.settings
, then you can additionally write at the beginningimport sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) # В последнем параметре указываем путь, откуда можно сделать импорт.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question