Readings: Intro to Django
Credit link: https://docs.djangoproject.com/en/4.1/
Django is an open source, Python-based MVC web framework that used to design website pages. Django Software Foundation (DSF) supports and maintains this open source framework.
Why use Django
Fast implementation and deployment of your web applications
Install Django, Create your framework and start your development, Django provides a rich, dynamic database-access API for fast developments.
-
Object-relational mapper
-
URLs and views
-
Templates
-
Forms
-
Authentication
-
Admin
-
Internationalization
-
Security
Django have design formats for all, you just need to modify accordingly.
Have everything you needed, not just a MWV framework
- embedded SQLite for database
- object-relational mapper
- Modularized packages for easy use
- free APIs(see up check marks)
- templates design
- Host header validation
- Cross-origin opener policy
Secure
- Cross site scripting (XSS) protection
- Cross site request forgery (CSRF) protection/Session security
- SQL injection protection
- Clickjacking protection
- SSl/HTTPS
Scalable
Django uses a SHARED-NOTHING architecture allow developers to add hardware at any level.
Maintainable
Django code is written using design principles and patterns that encourage the Don’t Repeat Yourself (DRY) principle so there is no unnecessary duplication, reducing the amount of code. Django also promotes the grouping of related functionality into reusable “applications” and, at a lower level, groups related code into modules, the MVC design pattern.
versatile for all web developments
from companies, governments to social media networks they are all using Django to develop their projects.
- Sportify
- Youtube
- Dropbox
- Disqus
- Knight Foundation
- MacArthur Foundation
- Mozilla
- National Geographic
- Open Knowledge Foundation
Steps of creating a Django project
- Install Django in env.
$ python -m pip install Django
- Create project, this command will automatically create all project needed template for fast developments
$ django-admin startproject your-project-name
- runserver to check the functionality of your init Django project
$ python manage.py runserver
- Create your app
$ python manage.py startapp app-name
- Write your view
- Map your url
-
routes
- Database setup if needed
- Create models
Projects vs. apps vs. models
An app is a Web application that does something;
A project is a collection of configuration and apps for a particular website.
A project can contain multiple apps.
An app can be in multiple projects.
A model is the single, definitive source of truth about your data.
Things I want to know more
- “MTV” framework or “model”, “template”, and “view.” sometimes used to call in Django, How does it compare to the MVC framework?
- More deep understanding project vs app vs model in Django.