我真的很怀疑使用哪一个(Formset 或 Inline Formset)。
我有一个在线送货申请表来预订自行车。有不止一种类型的自行车,因此我有两个模型“DeliveryRequests”和“DeliveryRequestBikes”。
class DeliveryRequests(models.Model):
pickup_date = models.DateField()
return_date = models.DateField()
pickup_hour = models.TimeField()
return_hour = models.TimeField()
name = models.CharField(max_length=100, null=False, blank=False)
email = models.EmailField(null=False, blank=False)
phone = models.CharField(max_length=25, null=False, blank=False)
location_name = models.CharField(max_length=100, null=False, blank=False)
address_to_delivery = models.CharField(max_length=200, null=False, blank=False)
message = models.TextField(null=True, blank=True)
deliveryrequeststatus = models.ForeignKey(DeliveryRequestStatus, null=False, blank=False)
comment = models.TextField(null=True, blank=True)
date_insert = models.DateTimeField(auto_now_add=True)
date_last_modification = models.DateTimeField(auto_now=True)
def __unicode__(self):
return self.name
class Meta: # To order in the admin by name of the section
ordering = ['-id']
class DeliveryRequestBikes(models.Model):
deliveryrequest = models.ForeignKey(DeliveryRequests, null=False, blank=False)
biketype = models.ForeignKey(BikeTypes, null=False, blank=False)
units = models.IntegerField(null=False, blank=False)
date_insert = models.DateTimeField(auto_now_add=True)
date_last_modification = models.DateTimeField(auto_now=True)
def __unicode__(self):
return self.deliveryrequest
class Meta: # To order in the admin by name of the section
ordering = ['biketype']
我忘了明确地说这是一种前端形式。我需要能够插入一个“DeliveryRequests”注册一个或多个“DeliveryRequestBikes”
我应该使用哪一个,Formset 或 Inline Formset?
请给一些建议。
此致,