Looking at a model structure like this:
class book (models.Model ): User = Model. Forward (user) class readdance (model.model): book = model. Forgreen (book) date = model.defild ()
In a book, many may have to read How do I list at least one I can do this: Is such a a Is it possible to do with the query, or is this the best way? .
reading
books within a specific year?
from- date = datetime.date (2010,1,1) to_date = datetime.date (2010,12,31) book_ids = Reading. Objects \. Filter (date__range = (from_date, to_date)) .values_list ('book_id', flat = true) books_read_2010 = Book.objects.filter (id__in = book_ids)
Book.objects.filter (readdate__date__year = 2010)
Comments
Post a Comment