Django ModelForm not saving data to database

前端 未结 6 2074
温柔的废话
温柔的废话 2021-02-10 05:53

A Django beginner here having a lot of trouble getting forms working. Yes I\'ve worked through the tutorial and browsed the web a lot - what I have is mix of what I\'m finding h

6条回答
  •  盖世英雄少女心
    2021-02-10 06:20

    I think you need to 1st create an object for ModelForm and then assign the object on if the request method is post. In your code you are only doing this for only one attribute and before checking the method. -Also in your forms.py ,in fields parameter of Meta() class, you used [] brackets which indicates what attributes must be excluded, but as your including all those attributes in form you must use () brackets. I think your code should be edited as follows:

    see here

提交回复
热议问题