【发布时间】:2021-03-15 16:23:49
【问题描述】:
我在django中有两个模型分别叫cattle和theft 我想介绍一个theft来删除获得的对象。不知道有没有可能。
class Ganado(models.Model):
unidad = models.CharField(max_length=150)
categoria = models.ForeignKey(Categoria, on_delete= models.CASCADE)
raza = models.CharField(max_length=10, choices=raza_choices)
color = models.CharField(max_length=10, choices=color_choices)
nume_marca = models.PositiveIntegerField()
lugar_marca = models.CharField(max_length=20, choices=marca_choices)
class Hurto (models.Model):
fecha = models.DateField()
ganado = models.OneToOneField(Ganado,null = True, on_delete = models.SET_NULL)
【问题讨论】:
标签: django-models django-rest-framework django-views django-queryset django-signals