python - Can't save a form in Django (object has no attribute 'save') -
the following form:
class advancedsearchform(forms.form): valueofres = forms.choicefield (label="res", choices = ((0, 0),(2.2, 2.2)), required= false)
the following view:
def advancedsearch(request): if request.method == "post": search = advancedsearchform(request.post, request.files) if search.is_valid(): new_search = search.save(commit=false)
i'm getting error 'advancedsearchform' object has no attribute 'save'
... why?
save
available modelform
default, , not forms.form
what need is: 1. either use `
class advancedsearchform(forms.modelform): valueofres = forms.choicefield (label="res", choices = ((0, 0),(2.2, 2.2)), required= false) class meta: model=search #or whatever object
or
2)
def advancedsearch(request): if request.method == "post": search_form = advancedsearchform(request.post, request.files) if search.is_valid(): cd = search_form.cleaned_data search = #populate searchobject() search.save()
Comments
Post a Comment