I would like to know if it would be possible to create only a custom class for my views in django that could be valid for different urls.
For example:
#urls.py
url(r'^$', CustomClass.as_view(), name='index'),
url(r'^other_url/(?P<example>[-\w]+)$', CustomClass.as_view(), name='other')
#views.py
CustomClass(View):
# for / url
def first_method(self, request):
pass
# for other_url/
def second_method(self, request, example):
pass
I have readed the documentation about class based views, but in the example only talks about a single url... https://docs.djangoproject.com/en/1.9/topics/class-based-views/intro/
So, I suppose I have to create a class for each url. But it would be possible use the same class with different methods for different url?