I am trying to create a helper function that validates forms. If the form is valid, then I will create an object in the database. The function takes in three arguments, the request, the form, and the model.
def form_validate(request, form, model):
form = form(request.POST)
print form
if form.is_valid():
print "the form is valid"
# create object using valid form
else:
print "the form is not valid"
# send back items
print form.errors.items()
If the form is valid, I want to use the form data to create a new model. How would I do that? I have tried to look at the Django docs(https://docs.djangoproject.com/en/dev/topics/forms/) but I cannot find the answer.