Skip to content
Advertisement

The view urlshort.views.page_redirect didn’t return an HttpResponse object. It returned None instead

I’m making a url shortener with django. I have a form that has a long_url attribute. I’m trying to get the long_url and add it to a redirect view with a HttpResponseRedirect.

JavaScript

When I go to the link, it gives me The view urlshort.views.page_redirect didn't return an HttpResponse object. It returned None instead. Does anyone know why this is happening?

Advertisement

Answer

It is not returning because there is no valid form, you need to redirect to a form for the user to enter data first, you will then get that data from the form to perform your redirect. additionally because a user is returning data you will need to get the data from request.POST.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement