Avoid redirect page in django

Viewed 30

this is my e-commerce portfolio page with password authentication.

Here the image is of two types

  1. blur and 2. original

main portfolio blur images (before entering password)

If the password is correct, the httpresponse returns the original image.

you can see url of portfolio website images before and after.

in that just want:

from: /trail/1234

to: /trail#1234

means don't want to redirect page

1 Answers

You could just render a different page depending on if the login is valid or not. (I'm not sure if you are doing a custom login View or using the default)

if login.valid(): # this line is prob not correct

    # redirect to correct page
    return HttpResponseRedirect(reverse('loginhome'))
else:
    # redirect to the same page but with a location hash
    return HttpResponseRedirect(reverse('loginpage')+"#invalid")

Also you could just, or as well, add a @login_required decorator to the other page. Even if they get redirected to that page, they'll be bounced back to the login.

Related