Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8483233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:02:26+00:00 2026-06-10T20:02:26+00:00

Hello? I am trying to redirect a particular user to a custom page once

  • 0

Hello? I am trying to redirect a particular user to a custom page once they log in in django. The Admin will be directed to their usual admin interface while this particular user will go to their own custom page.
I have written this code and placed it in my views

def custLogin(request):
    if request.user.username == '***':
        return HttpResponseRedirect('http://********************.html')
    else:
        return login(request,template_name='login.html')

I have pointed the accounts/login url in urls.py to custLogin as below

(r'^accounts/login/', custLogin),

I however keep getting the error

Caught NoReverseMatch while rendering: Reverse for 'django.contrib.auth.views.login' with arguments '()' and keyword arguments '{}' not found.

Any pointers please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:02:28+00:00Added an answer on June 10, 2026 at 8:02 pm

    Maybe, you should use redirect shortcut, which returns an HttpResponseRedirect, to point your users to different places after custLogin view processed.

    from django.shortcuts import redirect
    def custLogin(request):
        if request.user.is_staff:
            return redirect('/some/admin/url')
        else:
            return redirect('/some/regular/user/url')
    

    As documentation says, you can use the redirect() function in a number of ways: by passing a view name, an object or url. See documentation for more info

    Note, that I use is_staff user field to determine: is user an admin or not.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I am trying to create a custom expandable listview, but the documentation on
Hello Webmasters iam trying to redirect the webpage to a different URL/webpage after submitting
Suppose the user try to access the following web page on my website http://something.com/hello/hi.php
Hello im trying to make a small menu pop up once an item is
I'm trying to run some java script just before a page redirect but it
hello im trying to set custom errors. i got a form. actions to post.php
Hello I am trying to do a redirect if the response is a 404
Hello I´m trying to automate AZURE VM management like Amazon EC2. Is there any
Hello im trying to echo only the 50 letters, but something in my code
hello i am trying a sqlite database tutorial to build, but its not working

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.