61 - Manage QuerySets with Django Formsets + modelformset factory - Python & Django Tutorial Series

preview_player
Показать описание
61 - Manage QuerySets with Django Formsets and modelformset factory -Python & Django 3.2 Tutorial Series

Try Django 3.2 is a series to teach you the fundamentals of creating web applications with Python & Django by building a real project step-by-step.

Рекомендации по теме
Комментарии
Автор

Hi Justin! I apretiate a lot your work, very clear and neat explanations. I am following these series for a week :)

I just want to mention that the if-statment (if child.recipe is None) in 7:40 will cause an exception and as django docs suggest it's better to use the python function hasattr:

if not hasattr(child, 'recipe'):
child.recipe = parent

I am sure you solved this issue later on, but just in case :)

ramiboutas
Автор

Thank you so much i was waiting gor this .

تعلممهارهكليوم
Автор

Hi I have ben following this tutorial for some other app i was working on but I'm stuck here for quite some time. For some reason i keep getting ( (hidden field total_Forms, initial_form) this is required) on my page right before i put the formset tag.

can you help me with that?

nayankhemka
Автор

Thanks very much Justin. Well explained.

Here is something interesting and that I am curious about. When I use "{{formset.as_p}}" in the html template everything works fine. I can edit and change the values no problem. When I refresh the page/ check the admin the values are indeed changed.

However once I try rendering the values in the forms differently any updates I do on the (front-end) form won't take effect after saving. How is that? That makes literally no sense to me.

To clarify I use something like this on the front-end template for example:

{% for ingredient_form in formset %}
<p>{{ingredient_form.name}} .... </p>
{%endfor %}

It all renders out fine but as mentioned any values changed on the site won't "stick" once saved.

specimon
Автор

instead of teaching the way of NOT to do something, you must teach DIRECTLY de CORRECT way of doing it, because students may confuse thinking someting you just did is the correct way, at the end you ALWAYS say "THIS IS NOT THE CORRECT WAY OF DOING THIS..." and change everything we (the students) thought it was correct. that is not good practice teaching. even the videos would be shorter if you don't do that

techfinpro