Django Redirect Not Working

56 views
Skip to first unread message

göktürk sığırtmaç

unread,
Aug 24, 2019, 6:49:09 AM8/24/19
to Django users
Hello, my UserCreate class is create user via CreateAPIView. I want to check. if user is auth, auth user directly to 'profile' URI. 

class UserCreate(generics.CreateAPIView):

serializer_class = UserCreateSerializer
permission_classes = (~IsAuthenticated,)
queryset = User.objects.all()

def __init__(self):
if IsAuthenticated:
print("hello")
redirect("profile/")

code above is working print method but not working redirect method.

Aldian Fazrihady

unread,
Aug 24, 2019, 7:26:20 AM8/24/19
to django...@googlegroups.com
If that API is accessed via AJAX, then your JS code needs translate status 302 and Location header to JS code that sets "location.href"

Regards,

Aldian Fazrihady
http://aldianfazrihady.com

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d9369cce-3734-4bff-ac53-ce785918362b%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages