[Answered ]-Django: Adding files to a form gives multiple argument error

2👍

You override the __init__ method so that the first argument is user but you pass request.FILES instead. Change the line:

rec_form=salesmanform(request.FILES,request=request,user=request.user,data=request.POST)

to

rec_form = salesmanform(user=request.user, data=request.POST,
                        files=request.FILES, request=request)

As a rule of thumb, try not to mix named and positional arguments, especially when you change the class constructor signature. Also consider changing your form name to SalesmanForm to be more compliant with PEP-8 class naming conventions.

👤Selcuk

Leave a comment