Hello,

I have a few question with generic views as I can't manage to have all posts
related to a tag or category

My model is :

class Post(models.Model):
    author = models.ForeignKey(User)
    title = models.CharField(maxlength=50)
    summary = models.TextField(blank=True)
    message = models.TextField()
    category = models.ManyToManyField(Category)
    tag = models.ManyToManyField(Tag, blank=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
    pub_date = models.DateTimeField('Date de publication',
auto_now_add=True)
    pub_status = models.BooleanField('Publie ?', default=True)
    url = models.SlugField(prepopulate_from=("title",))

class Tag(models.Model):
    name = models.CharField(maxlength=50)
    description = models.TextField(blank=True)
    url = models.SlugField(prepopulate_from=("name",))

I try to play around with something similar to this in urls.py :

(r'^tag/(?P<slug>[-\w]+)/$', 'object_list', dict(queryset=
Post.objects.filter(tag='slug_field'), slug_field= 'url', )),

but did not manage to get anything except errors.

Idea is that all url with /tag/foo gives all posts that have the "foo" tag.

What would be the correct solution ? Do I have to do as James [1] suggests,
ie to filter it in views.py with some generic views methodes ?

So far I run .95 but can move to svn if it is worth :-)

Regards,
Nicolas

[1]
<http://www.b-list.org/weblog/2006/11/16/django-tips-get-most-out-generic-views>


--~--~---------~--~----~------------~-------~--~----~
 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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to