I have a django model:
class Book(models.Model):
[..]
and I want to have the model name as string: ‘Book’. When I try to get it this way:
Book.__class__.__name__
it returns ‘ModelBase’.
Any idea?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try
Book.__name__.Django models are derived from the
ModelBase, which is the Metaclass for all models.