Creating QuerySet object from last 7 days

posts = Post.objects.filter(author=member.user, xyz=xyz_id, pub_date >= datetime.datetime.now()-7)

I want to extract all posts by those requires of author and xyz which will be from last 7 days. Results only from last 7 days. I ofc know that this is wrong but I do not have idea how to code it.

Answers


from datetime import datetime, timedelta

posts = Post.objects.filter(author=member.user, xyz=xzy_id, pub_date__gte=datetime.now()-timedelta(days=7))

Need Your Help

jQuery Masonry and Ajax Append Items?

jquery ajax jquery-masonry

I am trying to use some ajax and the jQuery Masonry plugin to add some items - but for some reason the new items aren't getting the masonry applied ?

How to handle this kind of error index.php/something.php

php .htaccess

I want to redirect this kind of request to any other page.