0

I have added account app to installed_apps in my django project. also I have added urls of account app as like below:

(r"^account/", include("account.urls"))

Its working fine. Now I had to override SignupView class of account app. This is also working fine. Now I have created a new class CreateUser(SignupView) and I want that only admin user will be able to create user. So I added a different url for CreateUser(SignupView) view. Now I want that account/signup url with view SignupView will not be accessible anymore.

How can I block this particular url by keeping other urls active of account app as this is a library.

cjahangir
  • 1,773
  • 18
  • 27

1 Answers1

2

You can add a specific entry for the one URL that you wish to block before you include the packages urls.py. This will take precedence as Django loops over URLs in order looking for the first match

from django.views.generic.base import RedirectView

urlpatterns = [
    path('account/signup', RedirectView.as_view(url='/')),
    path('account', include('account.urls')),
]
Iain Shelvington
  • 31,030
  • 3
  • 31
  • 50