Skip to content

Instantly share code, notes, and snippets.

@pydanny
Created April 30, 2010 15:42
Show Gist options
  • Select an option

  • Save pydanny/385372 to your computer and use it in GitHub Desktop.

Select an option

Save pydanny/385372 to your computer and use it in GitHub Desktop.
"""
How to get the csrf_protect around a generic view. Which you need if you are working with comments.
"""
from django.conf.urls.defaults import *
from django.views.decorators.csrf import csrf_protect
from django.views.generic.list_detail import object_detail
from myapp.blog.models import Cartwheel
info_dict = {
'queryset':Cartwheel.objects.all(),
}
urlpatterns = patterns('',
url(
regex = '^(?P<slug>[\w-]+)/$',
view = csrf_protect(object_detail),
name = 'cartwheel_detail',
kwargs=dict(
info_dict,
template_name='cartwheel/cartwheel_detail.html',
)
),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment