8👍
✅
If you are inheriting from the generic list and detail views that django provides you could access self.model
to gain access to the model that the view displays information about, otherwise you will probably have use django’s resolve(): resolve(self.request.path)
.
You also could make your own View
subclass that you call with a keyword of your choice:
# views.py
from django.views.generic.base import View
class MyView(View):
app_name = None
# urls.py
from django.conf.urls.defaults import *
from some_app.views import MyView
urlpatterns = patterns('',
(r'^myview/', MyView.as_view(app_name='app_name')),
)
Then you should be able to access it through self.app_name
.
Source:stackexchange.com