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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:34:58+00:00 2026-05-25T09:34:58+00:00

I need to make a very simple modification — require that certain views only

  • 0

I need to make a very simple modification — require that certain views only show up when a user is not authenticated — to django-registration default views. For example, if I am logged in, I don’t want users to be able to visit the /register page again.

So, I think the idea here is that I want to subclass the register view from django-registration. This is just where I’m not sure how to proceed. Is this the right direction? Should I test the user’s authentication status here? Tips and advice welcomed!

Edit

I think this is the right track here: Django: Redirect logged in users from login page

Edit 2

Solution:

Create another app, for example, custom_registration, and write a view like this (mine uses a custom form as well):

from registration.views import register
from custom_registration.forms import EduRegistrationForm

def register_test(request, success_url=None,
             form_class=EduRegistrationForm, profile_callback=None,
             template_name='registration/registration_form.html',
             extra_context=None):
    if request.user.is_authenticated():
        return HttpResponseRedirect('/')
    else:
        return register(request, success_url, form_class, profile_callback, template_name, extra_context)

I had to use the same function parameters, but otherwise just include the test, and if we pass it, continue to the main function.

Don’t forget to put this in your URLConf either (again, this includes some stuff about my custom form as well):

top-level URLConf

(r'^accounts/', include('custom_registration.urls')),
(r'^accounts/', include('registration.urls')),

custom_registration.views

from django.conf.urls.defaults import *
from custom_registration.views import register_test
from custom_registration.forms import EduRegistrationForm

urlpatterns = patterns('',
    url(r'^register/$', register_test, {'form_class': EduRegistrationForm}, name='registration.views.register'),
)
  • 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-05-25T09:34:58+00:00Added an answer on May 25, 2026 at 9:34 am

    As far as I remember django-registration is using function-based views, so you can not really subclass them. The approach I usually follow is “overwriting” the original views (without modifying the django-registration app of course). This works like this:

    1. Create another app (you could call it custom_registration or whatever you want)
    2. This app need to contain another urls.py and in your case another views.py
    3. Copy the original register view code to your new views.py and modify it, add a pattern to your urls.py to point to this view (use the same url pattern as in django-registration for this view)
    4. Put an include to your projects urls.py of your new app urls.py before your are including the original django-registration app. This could look like this for example:
    urlpatterns = patterns('', 
        ...
        url(r'^accounts/', include('custom_registration.urls')),
        url(r'^accounts/', include('registration.backends.default.urls')),
        ... 
    )
    

    This simply works since the first matching url pattern for /accounts/register will point to your new app, so it will never try to call the one from the original app.

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

Sidebar

Related Questions

I need to make sure that user can run only one instance of my
I need to make a very simple drawing of a graph (NOT a chart
i need to take user input and make a very simple bar graph from
I need to make a kext which does a very simple function. Whenever a
I'm learning java and I'm trying to make a very simple application that does
I'm building a very simple mp3 player. What I need is to make it
Im trying to make a very simple application that lets my client create their
I would like to make a very simple ant script that does 1 thing,
I have a very simple game that consists of only one activity, and I
I want to do the following: I want to make a very simple gallery

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.