Roadmap for learning Django – the Python framework.

Django is a python web framework used for the development of full-stack web apps using python. Django is an open-source framework, it is maintained by most of the great developers, and its community is very large so if get stuck in any problem there are 99 percent chances that you will find its solution on the internet.

Advantages of Django

  • Django is based on Python programming language which is very easy to learn for beginners.
  • Django uses MVT (Model View Template) architecture, making the development process easier and faster.
  • Django has built-in support for Ajax, RSS, Caching, and other frameworks.
  • Django provides one of the best authentication system with built-in method for password hashing, login and logout system, permissions, etc.
  • Django comes with a built-in lightweight server for development purposes.
  • Most importantly it is used by companies like Instagram, Pinterest, Spotify, Mozilla, etc. because of its robustness.

So now let’s get into our main purpose to discuss the roadmap for Django cos that’s why you are here. So without further ado let’s get started.

Python Programming language

Obviously, you need to learn python to get started with Django since it is based on python. Here is the list of python topics that you need to learn before diving into Django if you really want to learn it.

  • Variables, Datatypes, Comments, Conditional Statements, For loops.
  • Collections in python – Lists, Dictionaries, Sets, Tuples.
  • Functions – args, kwargs.
  • Classes and their methods.
  • Modules and packages.
  • Decorators
  • Basic understanding of HTML and CSS

Now that you have learned Python so let’s talk about Django. To use Django you need to install Python and Django on your computer and to write code you need a code editor. Here I will recommend using VsCode.

Basic Terminal Commands

Wait, don’t get afraid they are just single-line commands once you get familiar with them they will become very easy for you to use on any machine. It will give you the feel of a hacker believe me.

Commands

  • django-admin startproject projectName – this command is used to start a Django project.
  • django-admin startapp appName – this command is used to create an app folder in the Django project.
  • python manage.py runserver – this command is used to run the development server that comes with Django.
  • python manage.py makemigrations - this command is used to create a model in your database.
  • python manage.py migrate - this command is used to execute SQL database commands to create your database files.
  • python manage.py createsuperuser – this command is used to create a super user for your application
  • python manage.py collect static – this command is used to collect all the static files in one single folder.

These are some basic terminal commands used to develop applications in Django. There are some more commands but you will need these commands for more than 90 percent of the time.

Django Views

Since Django is based on MVT architecture so you need to learn how to define views in your Django application. Views are Python functions that take HTTP requests and returns HTTP response like HTML documents. A web page that uses Django is full of views with different tasks and missions. There is a file in the Django app folder called views.py where you will write all the views functions.

Django Models

Django models are built-in features to create database tables and their files. Every models inherits from django.db.models.Model. Basically, it runs SQL commands for you and creates an SQL database table with files defined by you in models.py file present in Django’s app folder and you don’t need to care about SQL commands Django does everything for you.

Django Templates

A website or a webpage is nothing but a representation of HTML documents. So to represent something on a webpage you need HTML documents in which you represent data on webpages. Django provides built-in support for templates. Django has a mini-language for templates which is used to represent data and other things. To write HTML documents you will need to create a folder inside your Django’s app folder and inside the templates folder create a folder by your app’s name, (like appName), and then inside that folder create HTML files and connect that file with the views defined inside views.py inside the same app folder.

Authentication and Authorization in Django

Django is famous for its built-in authentication system. As I have said before Django provides one of the best authentication and authorization system. It handles user accounts, groups, permissions, and cookie-based user sessions. The Django authentication system handles both authentication and authorization. Briefly, authentication verifies a user is who they claim to be, and authorization determines what an authenticated user is allowed to do. Here the term authentication is used to refer to both tasks.

The auth system consists of: • Users • Permissions: Binary (yes/no) flags designating whether a user may perform a certain task. • Groups: A generic way of applying labels and permissions to more then one user. • A configurable password hashing system • Forms and view tools for logging in users, or restricting content • A pluggable backend system

Database Support

Django provides support for SQL databases and NoSQL like MongoDB. You just need to provide the database inside the settings file in the Django project and Django does everything for you without any problem.

Some other important concept

  • Get familiar with Django folders and files that come with Django when you start a project.
  • Learn how to handle media and static files.
  • Get familiar with the admin panel that comes with Django.
  • Learn how to deploy Django applications into the servers.

Conclusion

Django is one of the most demanding web frameworks for web development based on python so you need to learn python programming language before diving into Django. You will need to understand terminal commands to run Django app. Django works on the architecture of MVT so you need to learn how to connect all of them together so that it can appear on the webpage. Django provides one of the best authentication and authorization system.

Now it's your time to get started with Django All the very best