Skip to content

Instantly share code, notes, and snippets.

@meoooh
Created April 9, 2013 05:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meoooh/5343244 to your computer and use it in GitHub Desktop.
Save meoooh/5343244 to your computer and use it in GitHub Desktop.
#urls.py
from django.conf.urls import patterns, include, url
urlpatterns = patterns('',
url(r'^customer/(?P<slug>[^/]+)/$', cbv.as_view()),
# url(r'^customer/(?P<slug>[^/]+)/$', test),
)
#views.py
from django.views.generic import DetailView
def test(request, slug):
if request.method == "DELETE":
pass # blah blah some python code
else:
return cbv.as_view(slug=slug)(request)
class cbv(DetailView):
context_object_name = 'customerDetail'
template_name = "test.html"
allow_empty = True
model = Customer
slug_field = 'name' # name is exist in Customer model.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment