> Using .* in your URL regexes is not recommended, you only want to match
> what you absolutely need to match.  Something like the following would
> be better:
>
> (r'^tags/(?P<url>([a-zA-Z0-9-]+/)+)$', 'ssrc.blog.views.tags')

OK, cool. Thanks!

> This could be very much simplified now, and with the regex I mentioned
> above, the view would turn into something like:
>
> def tags(request, url):
>     # Don't need the last item in the list since it will
>     # always be an empty string since Django will append
>     # a slash character to the end of URLs by default.
>     tags = url.split('/')[:-1]
>     posts = Post.objects.filter(tags__name__in=tags)
>     return render_to_response("blog/tags.html", {'posts': posts})

If I'm not mistaken, __in will return results that aren't tagged by all
tags. So using the original example:

    Post1: articles, python, django
    Post2: articles, python
    Post3: articles, music

and tags has [articles, python, django], all 3 posts will be returned
since IN just OR's the values together, correct? That's why I came up
with that mess of a loop.


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