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

14th Apr 2023, 6:10 PM
Akash Gupta
Akash Gupta - avatar
5 Respuestas
+ 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.
14th Apr 2023, 6:19 PM
Justice
Justice - avatar
+ 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)
14th Apr 2023, 7:07 PM
Justice
Justice - avatar
+ 2
Justice Mirielle thanks both of you I just resolved my error you two are right there's a mistake in importing the correct module name not it resolved thanks.
15th Apr 2023, 5:03 AM
Akash Gupta
Akash Gupta - avatar
+ 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'......
14th Apr 2023, 6:40 PM
Akash Gupta
Akash Gupta - avatar