Skip to content

Instantly share code, notes, and snippets.

@tauzen
Created February 1, 2014 13:49
Show Gist options
  • Save tauzen/8752582 to your computer and use it in GitHub Desktop.
Save tauzen/8752582 to your computer and use it in GitHub Desktop.
Example of using login_required and staff_member_required decorators with Class-based views in Django.
from django.conf.urls import patterns, include, url
from django.contrib.auth.decorators import login_required
from django.contrib.admin.views.decorators import staff_member_required
from django.contrib import admin
from application.views import ApplicationFormView, ApplicationListView
admin.autodiscover()
urlpatterns = patterns('',
url(r'^$', login_required(ApplicationFormView.as_view())),
url(r'^applist/', staff_member_required(ApplicationListView.as_view())),
url(r'^admin/', include(admin.site.urls)),
)
@johntovor
Copy link

Thanks, boss. This helped me a lot.

@stevekim0417
Copy link

Thank you so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment