Top 9 Django Concepts - Part 1
Tags: python, webdev, beginners, career
Published: 2019-08-11 17:12:50

---
title: Top 9 Django Concepts - Part 1
published: true
description: The 1st part of a 3 part series on 9 concepts of Django to help any aspiring Django developer to accelerate their learnings  
tags: python, webdev, beginners, careers
canonical_url: https://www.maxongzb.com/top-9-django-concepts-part-1-4-mins/
---

![Photo by Med Badr Chemmaoui on Unsplash](https://images.ctfassets.net/ly2f59p4unnn/7FM0FXhYdHc3120JTUGjXE/b8bf92284e371be5e669a7a4b04f0826/med-badr-chemmaoui-ZSPBhokqDMc-unsplash.jpg)


# Introduction
![undraw complete design ongo][1]

When I first dive into Django after deciding to specialise as a Django developer. 

The number of concepts that are required for anyone to learn to understand Django can be overwhelming. 

Since Django development approach forces, you to develop in a **single** and **opinioned** way of web development with a **vast** ecosystem of packages to support your needs. 

This could discourage potential Django developers, who prefer **flexibility**, a lesser amount of **learning** and **unopinionated** approach to develop a web application using Python.

These are the people who want to get things done by picking their own adventure using a smaller amount of packages instead of Django's batteries-included approach.

In the first part of the series, I will be covering only **3** concepts and their related technical terms to help you get up to speed in using Django.

# Model View Template (MVT)
![MVT Diagram of Django by TutorialPoints][2]

The first concept might take some time for you to understand. While you are blazing through tutorials like [DjangoGirls][3]  or [Mozilla Developer Network's on Django ][4].

Django follows similar concepts like [Model View Controller (MVC)][5] or [Three-Tier Architecture][6]. 

Which seeks to make it **easy** for a developer to **maintain** and **manage** their codebase. 

By having **multiple separate** replaceable parts to form the whole software system.

## Model
**Bulk of your time is spent** here, on coding features you develop for your users or organisation which is usually called **business logic**. 

It is recognised by Django, whenever you create a new Django application. 

The model is called `models.py`, it resides in the application directory.

In this file, it also includes the database queries where you find **answers** from your records in the database.

Which you then pass the **results** of the query to your **view** and **template** to display it as a webpage.

## Views
Views consist of code that deals with **user interaction** like form submission by the user and **formatting** your answers from the database to **fit** your template. 

Before it is sent to your template file to be generated as a webpage.

It includes logic, like HTTP error responses (404 or 200 status code) based upon the answer that is founded by the database.

It could also be transferring of user interaction data for further processing by the **models.py**.

Do note that you should **never** include code that does heavy processing of data in **views.py**. 

As it dramatically **slows down** your display speed of the webpage. 

They are called [Fat Views and Skinny Models][7], whenever your identifying problems in display speed for a website. 

Therefore just stick with going **Fat Model and Skinny Views** as your best practice when developing your Django web application.

## Template
As the name suggested, it is a template that is used for generating an HTML file of a webpage for a website. 

You can think of it as similar to [markdown language][8].

Which is used to generate static sites or your project wikis in GitHub or GitLab.

To learn to embed a [Django Language Syntax][9] to display data for your template.

# Object Relation Mapping (ORM)
![undraw mind map cwng][10]

[ORM][11] for Django, allows you to focus on working with different types of database.

Without any knowledge related to that particular database to perform [CRUD (Create, Read, Update, Delete )][12] operations for your database.

This is a strength due to the reason that you are using a standardised way to perform **CRUD** operations to a database.

The weakness of this approach is the time taken to refactor to cater to certain features or design difference toward every database. 

Do note that it is recommended for you to use **Postgres** over **MongoDB** for the production-level environment.

The reason can be founded in this article, called [When to use MongoDB with Django][13] by **PyDanny** the author for [2 Scoops of Django][14].
 
# Administration Panel
![undraw server down s4lk][15]

This is by far the best feature of Django. 

Due to the reason that you do not need to spend a lot of time to create or customise your own user management.

The panel allows you, the management of your records for each table in the database from your `models.py`.

This could be customised further to suit your needs under the Django administration panel.

By importing codes like this under the name called `admin.py` file within your Django application. 

```python
from django.contrib import admin
from catalog.models import Author, Genre, Book, BookInstance

admin.site.register(Book)
admin.site.register(Author)
admin.site.register(Genre)
admin.site.register(BookInstance)
```

For further details on how to customise your Django administration panel. 

It could be founded in [Django project documentation][16], [Django tutorial by Mozilla][17] or an excellent video tutorial by [Dumbfounds][18]

# Conclusion
![undraw into the night vumi][19]

I hope that these 3 concepts are useful for you to help you to accelerate your learning on Django. 

Since these terms are quite confusing to me when I was starting out. 

While I do have a rough idea on what will be covered in this 3 part series.

I  would greatly appreciate that you could provide me with suggestions on Django concepts that might be confusing to you in the comments section.

If you like my article, please **sign up** for Max [Adventurer's Newsletter](http://eepurl.com/dOUoUb) for awesome content I stumble across weekly in **Python**, **Startup** and **Web Development**.

You can also **follow** me to get the **latest** update of my article on **Dev**

Besides that I looking to help out to **mentor** anyone who is interested to break into a startup. 

My available time is from **9 pm to 2 am GMT+8**, see you soon!!!. 

This post was originally posted on Max's blog at [Top 9 Django Concepts - Part 1: 4 Mins](https://www.maxongzb.com/top-9-django-concepts-part-1-4-mins/) and [Photo by Med Badr Chemmaoui on Unsplash](https://unsplash.com/photos/ZSPBhokqDMc)

# References
* [DjangoGirls Django Tutorial][3] 
* [Mozilla Developer Network's Django Tutorial][4]
* [Model View Controller (MVC)][5] 
*  [Three-Tier Architecture][6]
*  [Django Top 10 Mistakes][7]
* [Markdown Language][8]
* [Django Language Syntax][9]
* [Django ORM][11]
*  [CRUD (Create, Read, Update, Delete )][12] 
* [When to use MongoDB with Django][13]
* [2 Scoops of Django][14]
* [Django project documentation][16]
* [Django tutorial by Mozilla][17]
* [Dumbfounds][18]
* [Illustrations from UnDraw][20]


[1]: //images.ctfassets.net/ly2f59p4unnn/26bqIuRMy2rXjVhbvF82x2/3dbaf9e881dd90666138c5319635442d/undraw_complete_design_ongo.png
[2]: https://www.tutorialspoint.com/django/images/django_mvc_mvt_pattern.jpg
[3]: https://tutorial.djangogirls.org/en/
[4]: https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django
[5]: https://www.tutorialsteacher.com/mvc/mvc-architecture
[6]: https://www.techopedia.com/definition/24649/three-tier-architecture
[7]: https://www.toptal.com/django/django-top-10-mistakes
[8]: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet
[9]: https://docs.djangoproject.com/en/2.2/ref/templates/language
[10]: //images.ctfassets.net/ly2f59p4unnn/1xhry9I4lvu4phhHMn8Khw/29f2fde94dcedb456d894e040609af2f/undraw_mind_map_cwng.png
[11]: https://www.fullstackpython.com/django-orm.html
[12]: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete
[13]: https://www.pydanny.com/when-to-use-mongodb-with-django.html
[14]: https://twoscoopspress.com/products/two-scoops-of-django-1-11
[15]: //images.ctfassets.net/ly2f59p4unnn/Yb7jM5bZpYf3pzZtjv6os/5166e4958159a6db3201415ecac42f59/undraw_server_down_s4lk.png
[16]: https://docs.djangoproject.com/en/2.2/ref/contrib/admin/#modeladmin-objects
[17]: https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Admin_site
[18]: https://youtu.be/g5DTIiFAiSk
[19]: //images.ctfassets.net/ly2f59p4unnn/1vxZYiia4QmvmdlzLpFRPe/2e3a099236a18135483253cbe11d7d12/undraw_into_the_night_vumi.png
[20]: https://undraw.co/illustrations