Hi jbr3,
Check scrabala.com
Is it similar to what you are working on?

On 3/23/12, jbr3 <[email protected]> wrote:
> Hi again,
>
> I've been trying to figure this out for awhile, but to no avail. I'll
> try to list the problems I've had in understanding it.
>
> 1. I'm not sure what the forms.py file should look like.
>
> Going by Shawn's model, would it be something like:
>
> " class GuessForm(ModelForm):
>       class Meta:
>           model= Guess
>           exclude = ('user')     "
>
> This gives me a dropdown list of possible answers, but no form changes
> I've tried to make give me multiple radio buttons or multiple
> checkboxes. Have I selected the wrong model to make the modelform
> from ?
>
> 2. I don't completely understand the concept of using Booleans. I've
> added admin functionality to the app so I can add questions and
> potential answers as well as select (using a checkbox) the correct
> response. Based on the model Shawn provided, selecting one of the
> checkboxes generated in admin makes that choice true and the others
> false. The user's answer needs to be compared against these, but I
> don't understand how I would achieve that. I assume I'm supposed to
> set this up in the form, but I can't get the radio buttons or
> checkboxes to work there. I can successfully submit an answer from the
> dropdown, but I still have no idea how it would be compared to the
> stored boolean value. Do I have to write more code for this ? And what
> would the best way be to retrieve it ?
>
> Also, in the examples I've seen, BooleanField() in forms involves
> creating a list of choices in the form. But it doesn't seem like I
> would need such a thing if I'm just using radio buttons whose value
> will be checked against a changing option for each question. Yet I
> can't really see how an alternative approach would work.
>
> 3. I don't know what the template should look like. It seems like I
> should be mixing the form fields with data passed directly from the
> model by using views. In my view, I've set
> "Question.objects.get(id=1)" to a variable. I've passed that to the
> template. But I've also used "{{ form.as_p }}". That gives me the
> possible answers that had been entered in the admin in the template.
> But, the answers aren't generated as radio buttons with text next to
> them. It seems like I would have to pass the actual text of the
> answers using views (setting "variable.answer_set.all()  to another
> variable and then passing it to the template) and then generate radio
> buttons some other way. When I generated the buttons in the template,
> though, the submission failed. I don't see how these could be checked
> against the boolean value stored for the right answer. And, like I
> said, I can't figure out how to make them work properly with the
> form.
>
> I know I've asked this already, but is it possible for anyone to show
> some sample code so I can understand how this should be done using
> Shawn's models. I've been trying to get this for awhile now, but I
> still don't really understand it. I know there are about fifty
> different questions here, but if anyone could help out in any way it
> would be appreciated.
>
> Thanks
>
>
>
>
> On Mar 14, 11:36 pm, jbr3 <[email protected]> wrote:
>> Can anyone help me with some questions I still have about this ? I
>> haven't had much experience with web programming, so trying to
>> understand this is kind of challenging.
>>
>> 1. I created the models Shawn suggested. And I'm now able to add a
>> question and possible answers to it in the admin area. Each possible
>> answer has a checkbox next to it with the "Correct" label from the
>> model. Does setting the correct response require anything more than
>> selecting the appropriate checkbox and saving the question ?
>>
>> 2. I still don't understand how I'm supposed to combine these three
>> models together in order to get the right output for the user. I've
>> been trying different approaches in views.py, forms.py and my
>> template. But I can't really figure out how this should be set up. I
>> don't like to keep asking for such direct examples.
>> But would anyone be able to provide kind of an abstract view based on
>> the model Shawn provided.
>>
>> On Mar 11, 5:16 pm, jbr3 <[email protected]> wrote:
>>
>> > Thanks for responding Shawn. I guess I was thinking that if I wanted
>> > to save the user's responses and the correct answers a different model
>> > would be needed for both.
>>
>> > On Mar 11, 4:11 pm, Shawn Milochik <[email protected]> wrote:
>>
>> > > I think I'd do this:
>>
>> > > Models:
>>
>> > >      Question
>> > >          question text
>>
>> > >      Answer
>> > >          question foreign key
>> > >          answer text
>> > >          correct (boolean)
>>
>> > >      Guess
>> > >          user foreign key
>> > >          answer foreign key
>>
>> > > That should be all you need (along with the User model or your own
>> > > method of tracking unique users without forcing them to register).
>>
>> > > I don't understand what your fourth model is for.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to