views:

57

answers:

1

Hi, 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 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
A: 

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