I've tried 3 different approaches, and nothing seems to work. Here's my view:
def my_view(request):
if request.method == 'POST':
form = DealershipForm(request.POST)
if form.is_valid():
dealership = form.save(commit=False)
dealership.entered_by = User(id=2)
dealership.save()
messages.success(request, 'Dealership added.')
else:
form = DealershipForm()
return response(request, template='misc/my_template.html',
vars={'form':form})
I've also tried modifying the cleaned_data
just after form.is_valid
, I've tried setting initial
, and instance
, nothing seems to work!