Django round #1

As I’ve started using Django I came across some obstacles which I would like to point out.

Here’s my general thoughts about concepts and usage of particular functionalities.

MVC design pattern

The Model–View–Controller pattern is widely used in many implementations of various programming languages.

Model View Controller diagram
https://commons.wikimedia.org/wiki/File:ModelViewControllerDiagram2.svg

Components of the pattern:

Model – independent of the user interface, holds data and logic

View – representation of data to the user

Controller – controls the flow of information between the model and the view

 

But in Django they say it’s Model-View-Template:

Model – more or less the same like in MVC

Template (aka. View) – how data is presented

View (aka. Controller) – the framework itself, which data you see, not how you see

Models

After each change of the Model (models.py) you have to execute those commands:

  • python manage.py makemigrations

– packages up model changes into individual migration files (something like commits)

 

  • python manage.py sqlmigrate

– this additional step displays the SQL statements

 

  • python manage.py migrate

– applies those ‘commits’ to database

 

  • python manage.py showmigrations

– shows a list of project’s migrations and their status

 

 

to be continued…

Get Free Email Updates!

Signup now and receive an email once I publish new content.

I agree to have my personal information transfered to MailChimp ( more information )

I will never give away, trade or sell your email address. You can unsubscribe at any time.

Leave a Reply