On 9 February 2011 19:16, Phil M <phillip.mumf...@gmail.com> wrote:
> class SampleModelManager(models.Manager):
>    def published(self):
>        return self.get_query_set().filter(published=True,
> date__lte=datetime.datetime.now())
>

This is the source of your problem. Later, you have:

class SampleModelDetailView(DetailView):
   queryset = SampleModel.objects.published()

But this code is a class definition, so it will run only once on
application startup. DetailView is carefuly using clone(), to avoid
cache'ing issues, but it doesn't have a way to figure out, that it
should change one of the filtering params. See this paragraph[1] in
the docs. Your view should like something like this:


class PublishedDetailView(DetailView):
   queryset = SampleModel.objects.all()

   def get_queryset(self)
       return super(PublishedDetailView,
self).get_queryset().filter(published=True,
date__lte=datetime.datetime.now()) # or at least the datetime.now()
part mustbe dynamic


http://docs.djangoproject.com/en/dev/topics/class-based-views/#dynamic-filtering

-- 
Łukasz Rekucki

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to