0
I have in working in django in making a model i have got a error.
Is there anyone who works on django so that's became easier for me to explain the error. The error i getting in form method Unboundlocalerror Local variables contact reference before assignment
5 Respostas
+ 4
Do you have a code snippet we can look at to understand?
But also take notice of the error message. It's already giving you exactly what the problem is. Make sure you're not trying use variable before they have been made.
+ 3
Akash Gupta If Contact is a model, it's most likely using an uppercase. Python is case-sensitive.
So try this instead:
contact = Contact(name=name,.....the rest of the fields)
+ 1
Justice yes
def contact(request):
if request.method=='POST':
#error=None
name=request.POST.get('name')
email=request.POST.get('email')
phone=request.POST.get('phone')
desc=request.POST.get('desc')
contact=contact(name=name,email=email,phone=phone,desc=desc,date=datetime.today())
contact.save()
return render(request,"contact.html")
Getting error where i made a object contact=contact (name='name'......