I have 2 models called Car and Review . A user can write many reviews for a car. I am able to filter all the reviews for a certain car . The issue i'm facing is , I only want to filter all the reviews that belong to a particular car in less than 30 days and excluding the user who own the car.
This question support my question Getting all items less than a month old but I am unable to filter all the reviews that belong to a particular car in less than 30 days and excluding the user who own the car.
class Car(models.Model):
user = models.ForeignKey(User)
name = models.CharField(max_length=11)
class Review(models.Model):
created = models.DateTimeField(auto_now_add=True)
user = models.ForeignKey(User)
review = models.TextField()
car = models.ForeignKey(Car)
Filter all the review for a particular car
Car = Car.objects.get(pk=1)
Review = Review.objects.filter(car=Car)
Filter all the review for a particular car but it retrieves all the reviews for everycar in 30 days which I don't want . I want to retrieve only the reviews in less than 30 days for a particular car and excluding the user who own the car
Car = Car.objects.get(pk=1)
from datetime import datetime, timedelta
last_month = datetime.today() - timedelta(days=30)
Review = Review.objects.filter(car__in=car,review__gte=month)
My question is How can I filter all the reviews for a particular car in less than 30 days and not including the reviews of the user who own the car .
thank you for helping me