I'm learning about the modelforms helper, and it is my understanding that best practice for form validation will be simply saving the form to a DB model object after simple code like so:
def my_view(request):
# if this is a POST request we need to process the form data
if request.method == 'POST':
# create a form instance and populate it with data from the request:
form = MyForm(request.POST)
# check whether it's valid:
if form.is_valid():
form.save()
return redirect somewhere
else:
form = MyForm()
return render(request, 'mysite.html', {'form': form})
However, there is extra data I would like to add to this model object that isn't explicit in the form. For example, what if I wanted to add a date stamp to the object, generated on server side? How do I go about saving more information into the same model object, and what are the best practices for doing so?