List Info

Thread: RequestContext in Generic Views?




RequestContext in Generic Views?
user name
2007-12-17 22:27:01
Hello,

I'm fairly certain this is a really easy thing I'm just not
understanding. I have some generic views that I want to pass
a
RequestContext(request) object, but I'm not exactly sure how
to do so.
I've been passing a RequestContext to all of my other pages
using
render_to_response(), but I don't see any obvious way to do
so with
the generic views for CRUD. Here's the code:

login_required
def location_list(request):
   """
   Generic view for listing locations.
   """
   loc_set = Location.objects.all()

   pagevars = {
      "page_title": "Location List",
   }

   context_instance = RequestContext(request)
   return listviews.object_list(request, queryset=loc_set,
paginate_by=100,
                                  extra_context=pagevars,
                                  template_name='assets/
location_list.html')

So how do I stuff this context_instance variable until
there? The
reason for this is to render messages, right now I don't
have access
to them in generic views.

Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: RequestContext in Generic Views?
user name
2007-12-17 22:32:52
I know this has been asked a few times and the answer seems
to be that
this is already included in generic views by default, but
it's just
not showing anything in my {} variable on all of
my generic
views. If i send messages and go to a regular page that's
rendered
with render_to_response() and supplied a RequestContext, it
works.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: RequestContext in Generic Views?
user name
2007-12-17 22:45:15
Sorry for the spam, looks like I can just grab the messages
via
{{request.messages}} from within the templates.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )