开发者

How do I use inline formsets to link two or more forms?

I have the following models and I'd like to use them to generate a contact form...now I know I'm suppossed to use inline formsets, but I've never been able to make heads开发者_如何学JAVA or tails of how to make this work...I want to have the first name, last name, email, phone number, best time to contact, and the message in my view.

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


I managed to get an answer to this question at link text

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜