what is the meaning of this error

584 views
Skip to first unread message

Saeed Pooladzadeh

unread,
May 27, 2019, 7:49:25 PM5/27/19
to Django users
hello

Can you please help me to understand the meaning of this error:

NameError at /emp

name 'redirect' is not defined
Request Method:POST
Request URL:http://localhost:62597/emp
Django Version:2.2
Exception Type:NameError
Exception Value:
name 'redirect' is not defined
Exception Location:E:\Django_Try\bot4\bot3\saeed\views.py in emp, line 14
Python Executable:E:\Django_Try\bot4\bot3\env\Scripts\python.exe
Python Version:3.6.6
Python Path:
['E:\\Django_Try\\bot4\\bot3',
 
'',
 
'E:\\Django_Try\\bot4\\bot3',
 
'E:\\Django_Try\\bot4\\bot3\\env\\Scripts\\python36.zip',
 
'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python36_64\\DLLs',
 
'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python36_64\\lib',
 
'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python36_64',
 
'E:\\Django_Try\\bot4\\bot3\\env',
 
'E:\\Django_Try\\bot4\\bot3\\env\\lib\\site-packages']
Server time:Mon, 27 May 2019 23:01:46 +0000

 Is it mean Django cant understand the meaning of redirect??
But I have used redirect on my other project?

Lunga Baliwe

unread,
May 27, 2019, 8:51:29 PM5/27/19
to django...@googlegroups.com
You probably have to import and use like this 
https://docs.djangoproject.com/en/2.2/topics/http/shortcuts/#redirect

from django.shortcuts import redirect

def my_view(request):
    ...
    obj = MyModel.objects.get(...)
    return redirect(obj)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/938de80b-874f-4339-a8ec-000bda037e74%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages