Created
April 9, 2013 05:42
-
-
Save meoooh/5343240 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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