Delete manytomanyfield in Django
Posted
by Mike
on Stack Overflow
See other posts from Stack Overflow
or by Mike
Published on 2010-05-03T20:43:29Z
Indexed on
2010/05/03
20:48 UTC
Read the original article
Hit count: 441
django
|django-models
I have the following models
class Database(models.Model):
user = models.ForeignKey(User)
name = models.CharField(max_length=100)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
class DatabaseUser(models.Model):
user = models.ForeignKey(User)
name = models.CharField(max_length=100)
password = models.CharField(max_length=100)
database = models.ManyToManyField(Database)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
One DatabaseUser can have many Databases under it's control.
The issue I have if I go to delete a Database it wants to Delete the DatabaseUser also.. Is there a way to stop this from happening easily?
© Stack Overflow or respective owner