[Fixed]-Submitting a model class from view.py

1👍

You have to do action="#" in your form html because some browsers can not accept empty action values.

Also you have a mistake in this part of code:

submit= Campaign(username=request.user)
submit.save()

You have to get the form values into your object, you can do it this way:

submit = form.save(commit=False)
submit.username = request.user
submit.save()

0👍

Some browsers will fail to post if the action attribute is empty, try with

<form action="." method="POST">

Notice the dot “.”, since you are using the same view to display the form and process it the dot it’s ok.

Leave a comment