The core building blocks of Django: Models

Series: The core of blocks of Django

  1. The core building blocks of Django
  2. The core building blocks of Django: Models

Pretty much all interesting websites store and process data of some kind, by this I mean these using a database. Django has native support for the main popular relation databases through Models, migrations as the Object Relation Mapper (ORM).

What do those three components give you? A lot! Let's start with Models; these essentially represent database tables as a Python class fields are defined as class attributes which is where data is stored. Next there is migrations, with two simple commands Django will compute the difference between your code and the database to generate the commands required to migrate the database and of course apply those changes. Finally, there is the ORM, this allows a developer to query a Model and return data to the browser with ease or create new objects from the client.

Now we have the components of a fully functional website.