If a model e开发者_开发问答xist like
class Empprofile(models.Model):
name= models.CharField(max_length=255)
group = models.CharField(max_length=255)
description = models.CharField(max_length=1024)
class Details(Empprofile):
address1=models.CharField(max_length=255)
address2=models.CharField(max_length=255)
Views,
ep =Empprofile.objects.filter(name="Tom")
for e in ep:
//How to delete all objects from Details table
How to delete all objects Details related to it
Update:Want to delete all rows from Details
It looks like your Empprofile
and Details
classes are two separate, different types of object in the database. Based on the code shown, Details
takes the structure of Empprofile
and builds on it to make a Details
model (and associated DB table), but they're not linked at a database level.
Which means that if you want to delete all details to with name=Tom
, you need to do:
ep = Details.objects.filter(name="Tom").delete()
But, sounds like you may have to pause for a moment and check that your model layer is actually structured the way you expect it to be
精彩评论