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 8900623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:08:33+00:00 2026-06-15T01:08:33+00:00

The task is simple: If user visits site root then: if user is authenticated

  • 0

The task is simple:

If user visits site root then:
    if user is authenticated then:
        redirect to /dashboard/
    else:
        redirect to settings.LOGIN_URL

There are many ways to implement that, but I wonder if there is such way in which I do need to use only urls.py.

I found a solution with RedirectView login_required(RedirectView.as_view(url=my_url)), however then I can only write static my_url instead of reverse(), which is not flexible.

  • 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-15T01:08:35+00:00Added an answer on June 15, 2026 at 1:08 am

    You could use reverse_lazy (Django 1.4) in you url configuration, like so:

    from django.conf.urls.defaults import url, patterns
    from django.core.urlresolvers import reverse_lazy
    from django.shortcuts import redirect
    
    urlpatterns = patterns('',
        url(r'^/$', lambda request: return redirect(reverse_lazy('url_name')),
    )
    

    Another possibility is to define LOGIN_URL using reverse_lazy, so you could continue to use settings.LOGIN_URL in your redirects.

    Code is untested, might have a typo somewhere.

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

Sidebar

Related Questions

I'm interested in creating a plugin that does this simple task: Steps 1. User
Very simple question. I need to perform a task when the user closes his
Simple task: given that an article has many comments, be able to display in
I've a Windows Form Application that does a simple task : the user selects
I am trying to perform a very simple task which is Add the user
Im working on a simple task manager that would allow user to kill running
I have what should be a simple task - Populate a user variable using
The task is simple, and the answers might be many. But here goes: On
This somehow simple task is not so simple. I can get the number of
This should be simple task but i am not been able to find the

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.