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 trialNill Yadav
228 Pointsanswer.question = question in 'create_question' view
In answer.question = question, where is the 'question' coming from in 'create_question' view
1 Answer
Steven Parker
231,110 PointsI assume you're asking about line 131 in "learning_site/courses/views.py", and you can see where "question" is created and assigned in the first statement of "answer_form" on line 120:
question = get_object_or_404(models.Question, pk=question_pk)
Nill Yadav
228 PointsNill Yadav
228 PointsI get where the question is coming from in line 120, but it is also used in line 94 in 'create_question' view; where are we getting that 'question' from? Also, for none of the forms, the 'action' field is specified, so how does the form knows which view to go to when we hit the save or button??
Steven Parker
231,110 PointsSteven Parker
231,110 PointsOh, I see. I was looking at a different point in the video.
The "question" in "create_question" is created on line 89:
question = form.save(commit=False)
When no action is specified, the browser just refreshes the current page on submit.