1๐
โ
You need to construct the ReferralForm
with the data (request.POST
) and probably also with the files (request.FILES
).
A Form
without data is called an "unbounded" form, and unbounded forms are always invalid. You thus create a form with data with:
def submit_referrals(request):
form = ReferralForm()
if request.method == "POST":
form = ReferralForm(request.POST, request.FILES) # ๐ add data and files
if form.is_valid():
print("VALID")
referral = form.save(commit=False)
referral.user = request.user
referral.column_number = 0
referral.colour = "ffffff"
referral.save()
else :
print ("NOT VALID")
Source:stackexchange.com