Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » How to create multi-leveled forms with freeform entry options [RSS Feed]

#1 Jan. 20, 2011 18:35:19

Steven L.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

How to create multi-leveled forms with freeform entry options


One of our internal clients has asked for a form with the following
structure:http://ssecdn.net/marcomm_form.pdfAs you can see, there are a lot of checkboxes, and they (the client)
need to be able to add more via the admin.

I initially thought I'd store "Request Types" and "Requests" like
this:

class MarcommRequestType(models.Model):
name = models.CharField(max_length=255)
order = models.IntegerField()
is_active = models.BooleanField(blank=True, default=True)

class MarcommRequest(models.Model):
request_type = models.ForeignKey('MarcommRequestType')
name = models.CharField(max_length=255)
is_active = models.BooleanField(blank=True, default=True)


...and then, store each instance of the form with a ManyToManyField on
MarcommRequest, like this:

class MarcommTicket(models.Model):
created = models.DateTimeField(auto_now_add=True)
name = models.CharField(max_length=255)
department = models.CharField(max_length=255)
email = models.EmailField()
date_needed = models.DateTimeField()
requests = models.ManyToManyField('MarcommRequest')


That works perfectly, except for those questions that have "other" or
"date of event" or things of that sort. As far as I can tell, there's
no good way to have a third level of question to my form, if that
third level is any kind of text entry / non-relationship field.

I thought a possible solution might be to have a "sub question" model
that lets the admin users specify a label and field type, but then,
where do I save the *answers* to the sub-questions?

What's the most Djangonic / Pythonic way to do this type of thing? It
seems like the kind of problem someone might have faced before...

Thanks!
Steven L Smith
Web Developer, Nazareth College

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

  • Root
  • » Django
  • » How to create multi-leveled forms with freeform entry options [RSS Feed]

Board footer

Moderator control

Enjoy the 15th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support