我有一个django休息后端有几个模型如下:
class Hall(Product):
product = models.OneToOneField(Product, parent_link=True, )
localities = ChainedForeignKey(
Localities,
chained_field="city",
chained_model_field="city",
show_all=False,
auto_choose=True,
sort=True
)
landmarks = models.CharField(max_length=50, blank=False, verbose_name="Landmarks of the Marriage Hall", )
seating_capacity = models.IntegerField(null=False, verbose_name="Seating capacity of the Marriage Hall",)
ac = models.BooleanField(null=False, verbose_name="Is the Marriage Hall AC?",)
garden_lounge = models.BooleanField(null=False, verbose_name="Is the Marriage Hall garden_lounge?",)
comments = models.CharField(max_length=50, blank=False, verbose_name="Customer comments for this Marriage Hall", )
gallery = models.ForeignKey(Gallery, related_name='halls')
如果我必须从我的angular2前端创建/更新/删除模型实例(这是完全独立的),我需要遵循哪些步骤?
现在,除了以下模型之外,我还有序列化器:
class HallSerializer(serializers.ModelSerializer):
category = serializers.ReadOnlyField()
class Meta:
model = Hall
fields = '__all__'
另外,正如您所看到的,此特定模型的其他模型为 OneToOne 或 ChainedForeignKey ,如何处理?