R&D
Django Static File Handling
· β˜• 3 min read
1. Categories of Django Static Files Django static files fall into two categories: static and media. static: files referenced by pages, such as JS, CSS, and images media: files uploaded by users 2. Production Environment Configuration In production, you usually configure Nginx to forward static file requests while Django handles dynamic requests.

Large File Transfer in Django
· β˜• 3 min read
1. Returning the File Directly If the static file is at media/test.zip in the project root, you first have to read the file into memory and then transfer it. The code looks like this: settings.py configuration 1 2 PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media/') yourapp/views.py 1 2 3 4 5 6 7 8 9 10 11 12 from django.

Building a Django Development Environment with Vagrant
· β˜• 3 min read
Docker solves the problem of environment isolation on the same machine and improves the efficiency of operations and deployment. Vagrant gives developers a unified, near-fully-isolated environment for development and testing. This article mainly discusses how to build a Django development environment with Vagrant. Versions: VirtualBox 5.0, Vagrant 1.8. 1. Basic

Building a Django Development Environment with Docker from Scratch (6) uWSGI, Django
· β˜• 4 min read
1. Directory Structure The django-devops-uwsgi directory holds the image build files that package uWSGI and Django. It installs the necessary packages such as uWSGI, pip, and virtualenv into the image. When a container is created from the image, the start.sh script runs: it creates the Python virtual runtime environment, installs the dependency packages from Django’s requirements.

Packaging a Django Development Environment with Docker from Scratch (5) Nginx
· β˜• 3 min read
1. Directory Structure 1 2 3 4 5 6 7 8 9 10 11 12 β”œβ”€β”€ django-devops-nginx β”‚ β”œβ”€β”€ Dockerfile β”‚ └── nginx.repo β”œβ”€β”€ django-devops-compose β”‚ β”œβ”€β”€ docker-compose.yml β”‚ β”œβ”€β”€ www β”‚ β”œβ”€β”€ conf β”‚ β”‚ β”œβ”€β”€ nginx.conf β”‚ β”œβ”€β”€ log β”‚ β”‚ β”œβ”€β”€ nginx β”‚ β”‚ β”‚ β”œβ”€β”€ access.log β”‚ β”‚ β”‚ β”œβ”€β”€ error.