I recently ran into this same problem (I wanted to only show related
episodes that had been marked live). I ended up just making a method
on Podcasts to do it.

class Podcast(models.Model):
  ...some data fields...

  def live_episodes(self):
    return self.episode_set.filter(live=True)

class Episode(models.Model):
  episode = models.ForeignKey(Podcast)
  live = models.BooleanField()

Hope that helps,
Alex

On May 31, 6:26 pm, Tim <generic.tjohn...@gmail.com> wrote:
> Hi, I am having trouble getting the behavior I would like from a
> ManyRelatedManager.
>
> I have a many to many relationship with User and ModelB, with a join
> table ModelJ. Instead of deleting items in my database, I am simply
> marking them as deleted. I have a custom manager that filters out
> deleted objects as a first step. Everything was working fine until I
> ran across the following problem:
>
> To access objects of ModelB that a belong to a User, say user1, I use
> user1.modelb_set. Let's say user1.modelb_set returns modelb1, modelb2,
> and modelb3. Finally let modelj2 describe the relationship between
> user1 and modelb2.
>
> If I set modelj2.deleted = True, I was hoping that user1.modelb_set
> would only return modelb1 and modelb3. Unfortunately it still returns
> all three modelb objects. I guess this is because the "deleted"
> attribute is being set on the join table, and not the ModelB table.
>
> Does anybody know how to set up custom behavior for a
> ManyRelatedManager? Basically, I would like to break links between
> User and ModelB by marking their ModelJ link as deleted, not actually
> deleting it from the database.
>
> Thank you,
> Tim

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to