On 24/06/06, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> 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.

Thanks, that's great! I'll start using that.

I have another, smaller related problem with urls.
I can't do this
(r'^blogs/([_A-Za-z0-9-]+)/', include('bloghost.blog.urls')),
because then the captured bit after blogs doesn't go anywhere.
I have to do this:
..
(r'^blogs/([_A-Za-z0-9-]+)/', 'frontpage')),
(r'^blogs/([_A-Za-z0-9-]+)/feed/', 'rss')),
...

Which is fine really, more of an itch than anything else, but it'd be
nice to do it the Right Way(TM).

Thanks,
Frankie.

>
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to