Update tech_docs/python/django.md
This commit is contained in:
@@ -226,4 +226,57 @@ my_project/
|
|||||||
- Use feature flags for gradual rollouts
|
- Use feature flags for gradual rollouts
|
||||||
- Document APIs and complex functionality
|
- Document APIs and complex functionality
|
||||||
- Conduct regular security audits
|
- Conduct regular security audits
|
||||||
- Optimize for both mobile and desktop experiences
|
- Optimize for both mobile and desktop experiences
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Streamlined Django Setup with Conda and pip
|
||||||
|
|
||||||
|
## 1. Create environment.yml file
|
||||||
|
Create a file named `environment.yml` with the following content:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: django_env
|
||||||
|
channels:
|
||||||
|
- defaults
|
||||||
|
dependencies:
|
||||||
|
- python=3.9
|
||||||
|
- pip
|
||||||
|
- pip:
|
||||||
|
- -r requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
## 2. Create requirements.txt file
|
||||||
|
Create a file named `requirements.txt` with your Python package dependencies:
|
||||||
|
|
||||||
|
```
|
||||||
|
django==4.2.5
|
||||||
|
djangorestframework==3.14.0
|
||||||
|
```
|
||||||
|
|
||||||
|
## 3. Create and activate the Conda environment
|
||||||
|
Run the following command in the directory containing your environment.yml file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
conda env create -f environment.yml
|
||||||
|
conda activate django_env
|
||||||
|
```
|
||||||
|
|
||||||
|
## 4. Create Django project and app
|
||||||
|
```bash
|
||||||
|
django-admin startproject myproject
|
||||||
|
cd myproject
|
||||||
|
python manage.py startapp myapp
|
||||||
|
```
|
||||||
|
|
||||||
|
## 5. Update dependencies (when needed)
|
||||||
|
If you need to add new packages, update `requirements.txt` and run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
## 6. Recreate environment (for team members or new setups)
|
||||||
|
```bash
|
||||||
|
conda env create -f environment.yml --force
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user