Cara Menambahkan Bidang ke Django Forms CreateDeview
class MyModelCreateView(CreateView):
model= My_model
form_class = MyModelForm
template_name = "application/mymodel.html"
def form_valid(self, form):
# comment: this fn will return the data from the HTML form
# and add to it the missing attrs of the model then save it
form.instance.attr_1='string I want to save'
#to save a clean string pass it between '' not ""
form.instance.attr_2='a'
return super().form_valid(form)
yassine ouelhazi