class Item(models.Model):
    tags = models.ManyToManyField(Tag, through=Tagging)
    ...

class Tag(models.Model):
    ...

class Tagging(models.Model):
    item = models.ForeignKey(Item)
    tag = models.ForeignKey(Tag)
    ...

tagging = Tagging.objects.get(item=item1, tag=tag1)
tagging.delete() # then tag1 of item1 is deleted

On 8月17日, 下午7时12分, Jeremy Keeshin <jke...@gmail.com> wrote:
> I have an Item model that has many Tags. If I delete a Tag, I want to make
> sure the related Items are not deleted. I tested this out on my local
> database, and it seems that there are no cascading deletes with many to many
> fields. However, I previously deleted data accidentally with ForeignKeys
> because I did not understand cascading deletes, so I just want to make
> sure.
>
> I read in the docs that you can customize the on_delete behavior in Django
> 1.3, but I am not quite clear how this applies to ManyToMany fields. What is
> the delete behavior on ManyToManyFields?
>
> Thanks,
> Jeremy

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