skip to Main Content

Postgresql – Using field in Trunc's kind property

I use PostgreSQL in my project and have three related models: class Timer(models.Model): start = models.DateTimeField() end = models.DateTimeField() task = models.ForeignKey( Task, models.CASCADE, related_name="timers", ) class Task(models.Model): name = models.CharField(max_length=64) wanted_duration = models.DurationField() frequency = models.ForeignKey( Frequency, models.CASCADE, related_name="tasks",…

VIEW QUESTION

Html – Django Template how to get the value of a model through the OneToOneField

In my Django App i have Two Models and the User model from django.contrib.auth.models from django.contrib.auth.models import User class Room(models.Model): host = models.ForeignKey(User, on_delete=models.CASCADE, null=True) topic = models.ForeignKey(Topic, on_delete=models.SET_NULL, null=True) name = models.CharField(max_length=200) description = models.TextField(null = True, blank =…

VIEW QUESTION

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

Use objects from one django model to filter objects from another django objects – Mysql

I'm doing my studying project. I have 2 models: class RoutePoint(geo_models.Model): vehicle = models.ForeignKey(Vehicle, on_delete=models.CASCADE, null=False, blank=False, related_name='routepoints') point = geo_models.PointField() datetime = models.DateTimeField() class Travel(models.Model): vehicle = models.ForeignKey(Vehicle, on_delete=models.DO_NOTHING, null=False, blank=False, related_name='travels') begin = models.DateTimeField() end = models.DateTimeField() First…

VIEW QUESTION
Back To Top
Search