Reputation: 31548
IN my views.py , i want to get the Model name from self
I tried this self.__class__.__name__
but it gave me the class name of view not the Model
EDIT:
class ObjectCreate(CreateView):
def get_template_names(self):
m = self.__class__.__name__
Upvotes: 6
Views: 5090
Reputation: 51655
You can do that, in a model view, self is not an object model instance.
You should write:
self.model.__name__
Edited 6 years later due ihhcarus comment:
For Django 1.11 you can use
self.__class__.__name__
to get the model class name.
Upvotes: 9