def save(self, request=None):
You assign a default value of None
to request
in the definition of save
, so what happens when the caller of save
doesn't pass an instantiated request?
user_info = request.user #request is None here
That will throw the error you see. To mitigate, add a simple if request is not None
or similar statement.
EDIT
After seeing your views.py
, you are passing request.POST
to SubmitDomain
's __init__
magic method, which you have not defined. The way you have your modelform defined above, you would have to pass the request to save()
, not __init__()
, i.e.
form.save(request)