'How to get field value in django Model?

I have this code

class Book(models.Model):
    name = models.CharField(max_length=70)
    author = models.CharField(max_length=70)
    rating = models.IntegerField(default=None)
    volume = models.IntegerField(null=True, default=None)
    annotation = models.TextField(default=None)
    year = models.IntegerField()
    

I want to get a value from field right in class. For example, "Harry Potter" for name. I don't find method to do it.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source