首先,我有一个像这样的模型:
class Entries(models.Model):
COMPANY = 'Company'
SCHOOL = 'School'
TYPES_OF_ENTRY = (
(COMPANY, 'Company'),
(SCHOOL, 'School'),
)
city = models.CharField(max_length=50)
name = models.CharField(max_length=254)
typeOfEntry = models.CharField(max_length=20, choices=TYPES_OF_ENTRY, default=COMPANY)
address = models.CharField(max_length=50)
owner = models.CharField(max_length=30,null=True)
comment = models.CharField(max_length=254,null=True)
is_active = models.BooleanField(default=True)
class PhoneNumbers(models.Model):
entry = models.ForeignKey(Entries, related_name="phoneNumbers", on_delete=models.CASCADE)
phoneNumber = RegexValidator(regex=r'^\+?1?\d{9,15}$', message="Telefonas turi būti įvestas tokiu formatu: '+xxxxxxxxxxx'.")
class Emails(models.Model):
entry = models.ForeignKey(Entries, related_name="emails", on_delete=models.CASCADE)
email = models.EmailField(max_length=254)
为每个单独的模型编写了简单的表单。令我困扰的主要事情是如何制作一个可以在同一个帖子时间内收到少量电子邮件和电话输入的表单(有一个帖子请求)?第二个问题,是否可以制作一个包含所有模型字段的表单?
提前感谢您的回答和时间。