# maybe this method would help you if you are using generic class-based views?
--
E. Serkan Sökmen
-- class CollectionSidebarMixin(object):
# Add collections to the context
def get_context_data(self, **kwargs):
context = super(CollectionSidebarMixin, self).get_context_data(**kwargs)
context['collections'] = Collection.objects.all()
return context
# and you can use the mixin for list and detail views:
class CollectionList(CollectionSidebarMixin, ListView):
model = Collection
context_object_name = 'collections'
class CollectionDetail(CollectionSidebarMixin, DetailView):
model = Collection
context_object_name = 'current_collection'
On Tue, Feb 5, 2013 at 2:12 PM, Jonas Geiregat <jonas@geiregat.org> wrote:
On Tue, Feb 05, 2013 at 02:06:28AM -0800, Stefano Tranquillini wrote:I think that a Context Processor will be a better option.
> Now, i can create a base.html template where i render the data. but, how
> should i do the population of these lists?
> Should i create a middleware that for each request populates the lists?
> or what?
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
E. Serkan Sökmen
Django / Front-end Developer @Teknolab
Personal works: serkansokmen.com
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment