Django for Web Development๐
Django is a Python-based free and open-source web framework that follows the modelโtemplateโviews architectural pattern.
Why learn Django โ
Django is a popular web framework built on top of python. It helps programmers rapidly create maintainable and flexiable web applications powered by an SQL Database. Django takes care of much of the hassle of web development, so you can focus on writing your app without needing to reinvent the wheel. It is free and open source, has a thriving and active community, great documentation, and many options for free and paid-for support.
Install and setup stuffs ๐ง
Things you need and need not.
- A ๐ฅ๏ธ with any OS โ๏ธ
- A good light weight editor: VSCode, Atom, Sublime text โ๏ธ
- Using super light Notepad Text Editor โ
- Basic programming knowledge in Python โ๏ธ
Familiarity with the basics of python OOP
- Basic Web development knowledge โ๏ธ
- Basic knowledge of using a terminal/command line โ๏ธ
You should know how to install software packages on computer’s operating system.
Installing system-wide or in a Python virtual environment? ๐ค
If you install Django into the global environment then you will only be able to one version of Django on the computer. And if you want to create websites using the latest version of Django while still maintaining websites that rely on older versions, then you’ll have a problem here.
Thus, it is better to run apps within independent Python virtual environments which enables multiple different Django environments on a single computer.
Install Python ๐
Being a Python Web framework, Django requires Python. What version of Python should be used? ๐ฏ The python version supported by the your target django release can be used.
Install Django ๐
There are three ways to download Django:
- Installing an official release with pip.
This is the best way to get the latest stable version of Django.
- Use a version from your computer’s package manager.
- Installing the development version.
Head over to the Django documentation and install django into your system/virtual environment.
Building Web Apps using Django ๐ฅ
Django provides us with an amazing documentation which makes it easy for anyone new to web development to understand the concepts and get ahead with building their dream project.
Follow the official tutorial provided in the Django Documentation and build a basic poll application.
Challenge yourself! It’s time to try out a project of your own.
Project ๐ก Create a blogging website.
While working on your project learn more about using models, making queries, and the QuerySetAPI Reference.
Learn more about the Django administration site.
Get a grasp on writing views, templates, managing static files, and the URL dispatcher.
Learn to write class based views, built-in class-based generic views, and pagination
Learn how to use sessions.
Learn about User Authentication in Django and how to use the Django Authentication System.
Learn more about working with forms and the forms API, creating forms from models.
Learn about the Django Security features.
Testing you Django Application ๐โโ๏ธ
It’s nearly impossible to develop a website that would run perfectly in the first go, so it is necessary to test your application. But as your project grows it’s is not so practical to manually test your app, to resolve this Django provides you a test framework to automate unit testing.
Check out the Workshop: Test-Driven Web Development with Django by San Diego Python’s Workshop.
Deploying Django ๐ฅ
Now that you have developed a fully tested website you might want to deploy it as well, to do so head over to the Django documentation where they explain the different ways to do the same.
You can also head over to the Heroku docs and learn how to configure you Django apps for Heroku.
Building RESTful APIs with Django ๐ช
Django REST framework is a powerful and flexible toolkit for building Web APIs.
Other Python Web Frameworks โจ
Steps for doing projects ๐ฉโ๐ป
Some good starting projects:
- To-Do List
- Library management system
- An event website for College Fests