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 Inlines and Media Inline Model Formset

use of {{ form.id }} in the 'question_form.html'

What is the use of the variable {{ form.id }} in the 'question_form'.html? For some reason, when i remove the {{ form.id }} from the template, the save and delete functionality stops working, why is that??

1 Answer

Kyle Knapp
Kyle Knapp
21,526 Points

I haven't done this particular lesson myself, so this is just a guess, but {{ form.id }} is probably being used as a unique reference number for each form to keep track of which form to delete or update. If you remove that reference number, I'm guessing the client has no way of knowing which form is which, so it doesn't know what form data to save or delete.

Again, this is just a guess, anyone with more understanding of Django please feel free to correct me.