I am not using django forms for this. I did think along the lines of doing the following:
- implement the Question form, override __init__ in the model to return answers for that question,
- instantiate a form for each question, set model=whatever_model_in_current_loop and append it to a list,
- in the template, render them out
... but ...
How wuld I then access the forms collection in my view, say, from request.POST?
I think I may be trying to reinvent a wheel here.
On Mon, Jul 23, 2012 at 7:41 PM, Thomas Orozco <g.orozco.thomas@gmail.com> wrote:
Are you using django forms?
Should be pretty straightforward once you have the input nicely formatted to just count the number of fields that have been filled in.
Le 23 juil. 2012 19:01, "Babatunde Akinyanmi" <tundebabzy@gmail.com> a écrit :
Maybe I don't really understand the question but I think if you want
to check if the user has answered 3 questions, check from the keys in
request.GET or request.POST as the case may be.
On 7/23/12, Sithembewena Lloyd Dube <zebra05@gmail.com> wrote:
> Hi all,
>
> I have a dynamically generated dropdown in this fashion (when viewing
> source):
>
> <select name="question_3_answers">
> <option name="question_3_answer0"
> selected="selected"></option>
> <option name="question_3_answer_7}"
> value="question_3_answer_7">a) Spend the majority of time indoors</option>
> <option name="question_3_answer_8}"
> value="question_3_answer_8">b) Value superior darkness and consider in-car
> activation</option>
> <option name="question_3_answer_9}"
> value="question_3_answer_9">c) Value indoor clarity over outdoor
> darkness</option>
> </select>
>
> <select name="question_4_answers">
> <option name="question_4_answer0"
> selected="selected"></option>
> <option name="question_4_answer_7}"
> value="question_3_answer_7">a) Spend the majority of time indoors</option>
> <option name="question_4_answer_8}"
> value="question_3_answer_8">b) Value superior darkness and consider in-car
> activation</option>
> <option name="question_4_answer_9}"
> value="question_3_answer_9">c) Value indoor clarity over outdoor
> darkness</option>
> </select>
>
> How would one check, in a view, whether or not any of the dropdowns have a
> selected item? I basically need to ensure that users answer at least 3 out
> of 5 questions?
>
> Thanks ...
> --
> Regards,
> Sithembewena Lloyd Dube
>
> --
> 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+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
--
Sent from my mobile device
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
--
Regards,
Sithembewena Lloyd Dube
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment