I have a user model manager that looks like this:
class MyManager(models.Manager)
def get_query_set(self):
'''Only get items that are 'approved' and have a `pub_date` that is in
the past. Ignore the rest.'''
queryset = super(MyManager, self).get_query_set()
queryset = queryset.filter(status__in=('a',))
return queryset.filter(pub_date__lte=datetime.utcnow())
And it works quite well; however, I have a problem using Django generic.list_detailviews object_detailand object_list: the query set seems to load only once, and because of this, it does not retrieve the elements that should be, because, I suppose, the utcnow()time is called only once (when it first loaded).
I assume this is intentional and implied as a performance improvement. However, this means that the video is displayed elsewhere on the site (in places where I am not in the view object_detail) before they are available in the view object_detail(see urls.py below). This results in 404s ...
Any ideas? Or do I need to write my own custom views to avoid this?
Thank!
urls.py
url(r'^video/(?P<object_id>\d+)$',
list_detail.object_detail,
{ 'queryset': Video.objects.all(), },
name='video_detail',
),
source
share