Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Django Forms Model Forms Model Form for Answer

Save answer along with user info

Hello there!

I want to save answer along with user info. I am not sure what should I do for that matter. Should I add User as a ForeignKey to Answer model? Somehow, I also need to add radio bottom to the answer choices if the question is a multiple choice question and save it into database. Can you tell me please, what steps should I take to accomplish it?

2 Answers

Writing assignments require a lot of effort. You should conduct research on the topic under discussion, put your thoughts into a coherent text that is unique http://essaytools.com/service/plagiarism-checker/

Adding the ForeignKey sounds like a pretty good idea, either that or a user pk.

For the radio buttons add a choices kwarg. Then set a RadioSelect widget to your modelform. See http://stackoverflow.com/questions/30199471/how-to-specify-select-and-radioselect-in-a-modelform#answer-30200800 for an example of how to do this.

That's how I would do it at any rate.

Can you please help me to understand what should be my steps to save answers from a quiz? My quizzes will have multiple choice answers, essay kind answers and true and false answers. The data for the questions comes from different models.

Quiz will look something like that:

Do you like cats?

0 Yes

0 No

What is the capital of USA?

0 New York

0 Washington DC

0 Richmond

Was this quiz helpful?


Enter your answer here


Submit Quiz