Hi,

given the models

class VideoKeyword(models.Model):
    """Keywords assigned to video information."""
    name = models.CharField(max_length=120)

class Video(models.Model):
    """Videos, videos, videos!
    keywords_list = models.ManyToManyField(VideoKeyword)

this many2many relationship creates the tables app_video,
app_videokeyword and the intermediate table app_video_keywords_list.

In a view I receive some videokeyword id's existing in a Video to be
deleted. I tried

sql = 'videokeyword_id IN (keywords)' <-- (filling keywords
placeholder with the id's, of course)
keywords = get_list_or_404(video.keywords_list.extra(where=[sql]))
for k in keywords:
    k.delete()

but I found that this also deletes the keyword from app_videokeyword!

I don't like to write raw SQL, is there any way to treat the middle
table (app_video_keywords_list) or anything I'm missing in the db-api?
or shall I go for the raw SQL?

thanks in advance,

hector


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