buisness logic in Django
Django , a famous python web framework . this isn’t a tutorial but before you start any django tutorial I truly recommend to read this article in order to understand django’s business logic .😁
Django is based on MVT (Models Views Template) :
Models :
To connect your idea to the data base you should create a Model :it describes the entities you have and the relation between . in Models you can specify also customized user model since django is full with built in models .
and here the example:
Views:
Almost here goes the magic ! the views are were we define our functionalities : there class based view and function one .
In views we interact with models using defined roles .Because those functionalities will be exported to urls.py file and used.
and here the example:
Tempalte :
Exccpt building your API django have it’s own template that allows you to have a full stack project using it !
Templates are like html but they can contain logic : such as loops and conditions . those features are mainly related to specific data they get from Views. Another interesting topic concerning django template is inheritance. This concept handle repetitive parts of the project and make your project more organized and easier to scale.
Django templates are also adaptive to js,css and static files even bootstrap!
and here an example :
One last thing , django is very adaptive to scalable project.all the settings are gathered in settings.py and most important django defines a project as a set of ‘application’ so whenever you want to add a section to you work (for example authentication) it’s a very recommended to add an app emerging all the work (register login logout , user model …) and of course you declare it in settings.py .
this is to see how the project is scaled .
Django is framework for perfectionist with deadlines . as long as you understand this logic you will fall in love with django!😍
No comments