Live data from Hacker News

Learn web development: Django Web Framework

developer.mozilla.org

51–54 of 54 posts

Re: Learn web development: Django Web Framework

#52
post #33

Earlier quoted context omitted.

How did you solve the problem of bypassing modelforms? Same roadblock here...

you reference the model in the view and then tell the view to save it directly to the model using the "model = form field" type syntax to assign value and then .save() method to save. In the form field you are saving from, you write the form field value and then an empty space where the input value goes sort of like "form.cleaned_data.get("field name", " "). The second blank ""is the empty space where the field value…

This is helpful and gives me some new ideas to try. Thankyouverymuch

Re: Learn web development: Django Web Framework

#53
post #38
post #33

Earlier quoted context omitted.

you reference the model in the view and then tell the view to save it directly to the model using the "model = form field" type syntax to assign value and then .save() method to save. In the form field you are saving from, you write the form field value and then an empty space where the input value goes sort of like "form.cleaned_data.get("field name", " "). The second blank ""is the empty space where the field value…

Alternative is to use the modelform but not save the created/updated model automatically. Then you modify the resulting model object and save it manually as needed. Works also with models with m2m fields with Form.save_m2m().

Thank you

Re: Learn web development: Django Web Framework

#54
post #37
post #33

Earlier quoted context omitted.

you reference the model in the view and then tell the view to save it directly to the model using the "model = form field" type syntax to assign value and then .save() method to save. In the form field you are saving from, you write the form field value and then an empty space where the input value goes sort of like "form.cleaned_data.get("field name", " "). The second blank ""is the empty space where the field value…

"The second blank ""is the empty space where the field value goes." I'm not sure I understand what you're saying here, but I don't think this is right. cleaned_data is a dictionary, and so the second argument to get is a default value to use if there is no value corresponding to the key. So, in your example, if there's no value for "formfield1" in cleaned_data, it would return a string with a space in. This is probab…

Thank you
Post reply on HN