On Monday 03 April 2006 19:12, tonemcd wrote: > I'm using magic-removal and have a 'simple' model for a tag-based > posting system (which will turn into a voting and image uploading > system). > > Here's the model (slightly cut down to save space); > > class Tag(models.Model): > slug = models.SlugField( > 'Slug', > prepopulate_from=("title",), > help_text='Automatically built from the title.', > ) > title = models.CharField('Title', maxlength=30) > description = models.TextField( > 'Description', > blank = True, > help_text='Short summary of this tag' > ) > def __repr__(self): > return self.title > > and > > class Post(models.Model): > slug = models.SlugField( > 'Slug', > prepopulate_from=('title',), > help_text='Automatically built from the title.', > primary_key='True' > ) > assoc_tags = models.ManyToManyField(Tag) > title = models.CharField('Title', maxlength=30) > > What I want to do is get a list of posts that are related to a tag.
I think it will look like this, if t is a Tag: t.post_set.all() If you want to change 'post_set' to something else, you need to supply a 'related_name' keyword argument to the assoc_tags field. By the way, if you can get ipython for your system, you should really try it out - it makes finding these things out really easy. Luke -- "Cross country skiing is great if you live in a small country." (Steven Wright) Luke Plant || L.Plant.98 (at) cantab.net || http://lukeplant.me.uk/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---