[PYTHON] Web application creation with Django

I want to make a web application with Django. However, it is difficult because the things that can be done are too wide and you have to get used to each concept.

This page will probably be a reminder of the Django concept while doing the Official Tutorial.

What is Django in the first place?

Django is one of the libraries for creating web applications in Python. The main features are:

  1. ** Routing **: Connect to a specific Python function from the specified URL
  2. ** Rendering **: Dynamically generate HTTP response from Python function by using template
  3. ** O / R mapping **: Extract individual records as Python objects from the backend database

The first thing is a library for creating web applications using the MVC framework. By the way, Jinja is the one that separates only the rendering motif, so the expression method around here is very similar to Jinja.

Unlike Flask, which is a similar (?) Routing library, it has a lot of functions such as database I / O and user authentication, so it is convenient when you want to quickly create a slightly elaborate application. However, since there are so many internal modules, Flask may be easier to understand if you only need simple functions (such as returning JSON).

It can also be used on Heroku (should).

Projects and applications

As a quick understanding:

-** Project : A term that refers to the entire area of the app you are trying to create - Application **: Individual domain created inside the application

For a service like a CMS, for example, one service may include separate features such as Wiki, blog, and chat (whether it's design or not). It can be said that an application corresponds to an individual function in such a case.

Or, as another possibility, you could think of your application as a microservices implementation (although Django is basically an O / R mapper, so I think such a design wouldn't work very well). ..

Both projects and applications are represented in Django as Python modules and submodules, both of which can be separated into MVC chunks. Generally, in routing, the project corresponds to the / (root) URL of the service, and each app hangs below it with a URL like / <app-name> / .... Often.

Project operations

When starting to develop one service (project), first make a boilerplate for the project:

gwappa: myrepo$ django-admin startproject <project-name>
        #Under the current directory<project-name>Directory is created,
        #Basic files are written in it

Subsequent project operations are performed using the file manage.py in the<project-name>directory created by startproject:

#Continuation of the above operation
gwappa: myrepo$ mv <project-name> src #It's okay to rename the outer directory
gwappa: myrepo$ cd src
gwappa: src$ python manage.py ... #Project operations

Creating an application

From manage.py, use the command startapp:

gwappa: src$ python manage.py startapp <app-name> #Unique name for each app

This will create a <app-name> directory inside the project directory and place the boilerplate files in it.

Recommended Posts

Web application creation with Django
Build a web application with Django
I made a WEB application with Django
WEB application development using Django [Admin screen creation]
Web application development with Flask
Web application with Python + Flask ② ③
Real-time web with Django Channels
Web application with Python + Flask ④
"Trash classification by image!" App creation diary day3 ~ Web application with Django ~
Web application made with Python3.4 + Django (Part.1 Environment construction)
Try creating a web application with Vue.js and Django (Mac)-(1) Environment construction, application creation
WEB application development using Django [Django startup]
WEB application development using Django [Application addition]
Measure Django application coverage with Coverage.py
Deploy a Django application with Docker
If you know Python, you can make a web application with Django
WEB application development using Django [Model definition]
WEB application development using Django [Initial settings]
Internationalization with django
[Day 4] Application creation
Web App Development Practice: Create a Shift Creation Page with Django! (Shift creation page)
django table creation
WEB application development using Django [Request processing]
WEB application development using Django [Template addition]
[Python] A quick web application with Bottle!
Application development using SQLite with Django (PTVS)
CRUD with Django
Run a Python web application with Docker
Launched a web application on AWS with django and changed jobs
Ramen map creation with Scrapy and Django
Web App Development Practice: Create a Shift Creation Page with Django! (Introduction)
Easy-to-understand explanation of Python Web application (Django) even for beginners (2) [Project creation]
Create a one-file hello world application with django
Authenticate Google with Django
Upload files with Django
Development digest with Django
Django python web framework
Output PDF with Django
Markdown output with Django
Twitter OAuth with Django
Django shift creation feature
Getting Started with Django 1
The story of making a web application that records extensive reading with Django
Send email with Django
File upload with django
Use LESS with Django
Web application using Bottle (1)
Pooling mechanize with Django
Easy-to-understand explanation of Python Web application (Django) even for beginners (3) [Application creation / DB setting]
Use MySQL with Django
Start today with Django
Getting Started with Django 2
Procedure for creating an application with Django with Pycharm ~ Preparation ~
Looking back on creating a web service with Django 1
(Python) Try to develop a web application using Django
Django tutorial (blog application creation) ② --model creation, management site preparation
Parse and visualize JSON (Web application ⑤ with Python + Flask)
Launch a Python web application with Nginx + Gunicorn with Docker
Looking back on creating a web service with Django 2
Single sign-on to your Django application with AWS SSO
A memo about building a Django (Python) application with Docker