What happens line by line after I register a model in django

I’m new to programming and I don’t really understand what’s going on line by line in the code

For example: to register a model in Django, we can register the class “class Genre(models.Model)” and specify only one field, for example “models.Charfield.”

In turn, the parent class “Model(metaclass=ModelBase) (django.db.models.base)” contains about 50 methods. Most of them are private


  1. Were these 50 methods called when I registered the model?
  2. If “yes”, which line of code is responsible for this call? Or which principle of OOP?
  3. Could you recommend any article or book to delve into this topic?

Thanks in advance!

This creates a new class derived from the models.Model class provided by Django with a character field named whatever with all the Django magic to manipulate the object and store it in a database. Nothing (really) happens with a class definition until it is instantiated as an object later (like when you create a new genre with genre = Genre()), which will then call the class’s __init__() method, which may call the superclass’s __init__() methods and who knows what else.

I’m not sure what you need as a reference. You can search for guides to programming in python, or object oriented programming in python, or any number of Django tutorials or the Django documentation. There’s a lot of information out there.