我有以下模型,我想用它们来生成一个联系表单......现在我知道我应该使用内联表单集,但我从来没有能够对如何制作这个做出正面或反面工作...我想知道名字、姓氏、电子邮件、电话号码、最佳联系时间以及我认为的消息。
class BestTime(models.Model):
contact_time = models.CharField(max_length=20)
start_time = models.TimeField()
end_time = models.TimeField()
def __unicode__(self):
return self.contact_time
class Customer(models.Model):
date_time_added = models.DateTimeField(default=datetime.today)
first_name = models.CharField(max_length=20)
last_name = models.CharField(max_length=20)
email_address = models.CharField(max_length=75)
phone_number = models.CharField(max_length=20)
best_time_to_contact = models.ForeignKey(BestTime)
def __unicode__(self):
return self.first_name
class MessageType(models.Model):
type = models.CharField(max_length=20)
def __unicode__(self):
return self.type
class Message(models.Model):
date_time_added = models.DateTimeField(default=datetime.today)
message_type = models.ForeignKey(MessageType)
customer = models.ForeignKey(Customer)
message = models.TextField()
def __unicode__(self):
return self.date_time_added