skip to Main Content

Postgresql – How to query a Django (DRF) model to get it with other model data attached?

I have a Post model: class Post(models.Model): profile = models.ForeignKey(Profile, related_name="posts", on_delete=CASCADE) project = models.ForeignKey(Project, related_name="posts", on_delete=CASCADE) title = models.CharField(verbose_name="Title", max_length=150) body = models.TextField(verbose_name="Content", max_length=1300) image_url = models.URLField(max_length=256, null=True, blank=True) liked_by = models.ManyToManyField(Profile, related_name="post_likes") date_published = models.DateTimeField(auto_now_add=True, verbose_name="Date published") date_modified…

VIEW QUESTION

Postgresql – session close is not working in python i m using sqlalchemy close() not working still i am getting session

> user = Session.query(User).filter_by(id=user_id).first() > print("Active Session", {'id': user.id, 'email': user.email} ) > Session.commit() > Session.close() > user = Session.query(User).filter_by(id=user_id).first() > print("After closing session", {'id': user.id, 'email': user.email}) i am trying to close session using python and sqlalchemy but after…

VIEW QUESTION
Back To Top
Search