from django.conf.urls import url
from demo import views
urlpatterns = [
url(r'/(?P[0-9]{4})' , views.DemoView.as_view(), name='demo')
]
from django.views.generic import View
from django.http import HttpResponse
class DemoView(View):
def get(self, request, year):
return HttpResponse(year)
# 也可以用**kwargs获取
def get(self, request, **kwargs):
return HttpResponse(kwargs.get('year'))
大家有问题可以微信交流一下~~