This repository is specifically meant to those who are looking into using Django, since this gives a good amount of information about Django and it's capabilities.
Disclaimer: I have also included a bootstrap boilerplate for this project.
Since newer versions of Python are often faster, have more features, and are better supported, the latest version of Python 3 is recommended.
- What is Django
- Building Web Applications
- Security
- Packages
- Documentation
- Open Source Community
- Installing Django
- Articles
- Thanks
Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it 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’s free and open source.
To give you an idea what the capabilities of Django are, here is a list of big companies that use Django:
- Disqus
- Spotify
- YouTube
- The Washington Post
- Dropbox
- BitBucket
- Mozilla
- National Geographic
Django's Architecture
Django has adopted Python’s "batteries included"
approach, the framework has everything necessary to create a fully developed application without needing to install any packages.
You can start building a simple application instantly without needing to customize it since all of the essentials are already available.
Django's structure mainly consists of:
- The Model Layer
- The Views Layer
- The Template Layer
- The Development Process
- Security
- The Admin
- Forms
Django, at it's core is just a series of components of Python, wired up and ready to go. Components are not dependent on each other, since they are separate entities. You can choose, pick, unplug and replace them when your app requires for that to be done. Meaning you can build up to whatever level of performance you need, without compromising the functionality of your app.
Django follows the DRY principle
. You have a Model and it has some fields with restrictions and rules e.g. integer field
, string field
with length constraint etc. You are going to take input from the users and want to save it in the Model and therefore need to validate the user inputs. You don’t have to write same fields and rules again. You just need to create a ModelForm
class and it’ll use the field and rules from the Model class.
By default, Django prevents most common security mistakes:
-
XSS (cross-site scripting) protection - Django template system by default escapes variables, unless they are explicitly marked as safe.
-
CSRF (cross site request forgery) protection - Django has built-in protection against most types of CSRF attacks, providing you have enabled and used it where appropriate.
-
SQL injection protection - Django uses built-in ORM, thus there is no risk of SQL injection (raw queries are possible, but by no means something that a beginner would need to use).
-
PBKDF2 password hashing - Django uses the PBKDF2 algorithm with a SHA256 hash, a password stretching mechanism recommended by NIST. It’s quite secure, requiring massive amounts of computing time to break. Depending on your requirements, you may choose a different algorithm, or even use a custom algorithm to match your specific security situation.
More on django security.
If you happen to need more than Django offers, searching for "django"
on PyPI
finds lots of available for use.
A list of awesome Django packages (not in a specific order):
- django-allauth
- django-channels
- django-contact-form
- django-compressor
- django-crispy-forms
- django-filter
- django-rest-framework
- django-tables2
- django-taggit
- django-sorting-field
- django-environ
- django-fsm
- django-registration
- django-two-factor-auth
- django-favorite
- django-debug-toolbar
- django-redis
- django-model-utils
- django-extensions
- django-cors-headers
- django-sendsms
- django-csp
Django’s official documentation is more than enough. On top of that, Stack Overflow is well-stocked with questions & answers related to Django.
Being open source and insanely popular, Django has created a helpful community.
Django has created a lot of libraries of its own, but not any for testing. It doesn’t mean that Django doesn’t support testing, it most certainly does. They have a complete section dedicated to testing. Python itself provides a great testing library for Django, so it wouldn't be very practical to develop a testing library.
-
Install pip. The easiest is to use the standalone pip installer.
-
Take a look at virtualenv and virtualenvwrapper. These tools provide isolated Python environments, which are more practical than installing packages systemwide.
-
After you’ve created and activated a virtual environment (you do not need a virtual environment, but it is highly suggested).
Enter the command:
pip install django
You can also download it from GitHub directly
git clone https://github.com/django/django.git
- Django vs. Flask in 2019: Which Framework to Choose
- Uses of Django
- When to choose Django
- Django Interview Questions
- Top 10 Django mistakes
- Creating custom template tags in Django
- How to host Django app on Pythonanywhere for Free
- How to make a blog with Django
Thanks to these awesome contributors for helping with this repository.