On Fri, 2006-06-23 at 17:58 +0100, Frankie Robertson wrote: > Please, is there any way of doing this? I've dumped the last approach, > I'm planning on using inclusion tags to query the database, but the > templates would still need to know the slug of the hostee's current > page. So generic views don't work because they don't know what the > blog_slug is, as it is I'm not replacing the generic views with my > own, not very DRY, but hey. To be honest I feel this is a bit of > failing in django and may file a bug, not sure how it would be > corrected to be honest though.
Any time you want to pass extra information to a generic view that you cannot just pass in from the URLConf, call your own view function that works out the extra information and then calls the generic view as its last step. You can still use the generic views, but you do a little bit of pre-processing first to get the information you need (in this case, populating extra_context, but sometimes even working out a more complicated queryset to pass in). That is not a flaw in the generic views, since it is so easy to write the wrapper function and if Django accommodated every single customisation possibility in the generic views that would become very difficult to maintain and understand. So you would write def my_view(request, ....): # ... work out whatever you need from the passed in params, etc. # Collect the information you need for passing to the generic # view and then just call it extra_context = {...} return list_detail(..., extra_context = extra_context) This is a very common pattern. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---