Steps to Push Django Project

Follow these steps to successfully deploy your Django project to your local Proxmox server.

1
Step 1

Django Init

Sub-step 1

Choose a project name

Comment: Here : C:\DaniIT\DjFull107
1
Step 1

Django Init

Sub-step 2

⚠️ if the project is copied, remove .git folder

1
Step 1

Django Init

Sub-step 3

⚠️ if the project is copied, delete db.sqlite3

1
Step 1

Django Init

Sub-step 4

Design a simple Django with AI

1
Step 1

Django Init

Sub-step 5

Check the DB config and run migrations

Comment: Verify database settings and run python manage.py migrate
1
Step 1

Django Init

Sub-step 6

Check that the Django app start wells

2
Step 2

Proxmox Server Setup

Sub-step 1

Proxmox Server Setup

2
Step 2

Proxmox Server Setup

Sub-step 2

Connect to proxmox

Comment: https://192.168.1.10:8006/
2
Step 2

Proxmox Server Setup

Sub-step 3

Create LXC

Comment: Check carefully the number
2
Step 2

Proxmox Server Setup

Sub-step 4

Choose root password

Comment: Store it in Login.xlsx
2
Step 2

Proxmox Server Setup

Sub-step 5

First step SSH Key

Comment: Use multiLXC
2
Step 2

Proxmox Server Setup

Sub-step 6

Update KB

Comment: Chart SSH Keys Management
2
Step 2

Proxmox Server Setup

Sub-step 7

Choose IP address

Comment: Acording to figures
2
Step 2

Proxmox Server Setup

Sub-step 8

Test local connection with SSH

Comment: ssh -i ~/.ssh/multiLXC root@192.168.1.27
3
Step 3

Router configuration

Sub-step 1

Router configuration

Comment: http://192.168.1.1/
3
Step 3

Router configuration

Sub-step 2

DHCP Binding

Comment: Get mac address in proxmox/LXC/Network
3
Step 3

Router configuration

Sub-step 3

Port Forwarding Web

Comment: Do not forget to enable
3
Step 3

Router configuration

Sub-step 3

Port Forwarding SSH

Comment: Do not forget to enable
3
Step 3

Router configuration

Sub-step 4

Test external connection with SSH

Comment: ssh -i ~/.ssh/multiLXC root@91.149.187.178 -p 40522
4
Step 4

SSH configuration

Sub-step 1

Open KB

Comment: https://knowledge-daniit.xn--80ahnax6a.com/projects/proxmox.html#ssh-config-setup
4
Step 4

SSH configuration

Sub-step 2

Edit ssh config and update it with the new IP

Comment: C:\Users\lomin\.ssh\config
4
Step 4

SSH configuration

Sub-step 3

Define ssh lxc-107

4
Step 4

SSH configuration

Sub-step 4

Test locally ssh lxc-107

Comment: ssh lxc-107
5
Step 5

Production settings

Sub-step 1

Production settings

Comment: Name it: settings_production.py
Setup File Available: View Configuration
5
Step 5

Production settings

Sub-step 2

Configure production database settings

Comment: Update DATABASES configuration for production
5
Step 5

Production settings

Sub-step 3

Set DEBUG = False

Comment: Disable debug mode for production
5
Step 5

Production settings

Sub-step 4

Configure ALLOWED_HOSTS

Comment: Add your domain/IP to allowed hosts
5
Step 5

Production settings

Sub-step 5

Set up static files configuration

Comment: Configure STATIC_ROOT and STATICFILES_DIRS
6
Step 6

GitHub Repository

Sub-step 1

Create .gitignore file

Comment: Create .gitignore file in project root with Django-specific exclusions
6
Step 6

GitHub Repository

Sub-step 2

Open Source Control panel

Comment: Click on Source Control icon in Cursor sidebar (Ctrl+Shift+G)
6
Step 6

GitHub Repository

Sub-step 3

Initialize repository

Comment: Click 'Initialize Repository' button in Source Control panel
6
Step 6

GitHub Repository

Sub-step 4

Stage all files

Comment: Click '+' next to 'Changes' to stage all files, or use 'Stage All Changes'
6
Step 6

GitHub Repository

Sub-step 5

Create initial commit

Comment: Type commit message and click 'Commit' button (Ctrl+Enter)
6
Step 6

GitHub Repository

Sub-step 6

Publish to GitHub

Comment: Click 'Publish to GitHub' button in Source Control panel
6
Step 6

GitHub Repository

Sub-step 7

Configure repository settings

Comment: Choose repository name, visibility (public/private), and click 'OK'
6
Step 6

GitHub Repository

Sub-step 8

Verify repository creation

Comment: Check that repository appears on GitHub.com with your code
7
Step 7

GitHub Setup

Sub-step 1

Update GitHub Secrets at a directory level

GitHub Setup Required: View GitHub Setup Guide
Comment: Add HOST, USERNAME, PERSONAL_ACCESS_TOKEN and PORT
7
Step 7

GitHub Setup

Sub-step 2

Update Deployment Workflow

Comment: Your deploy.yml now uses HTTPS token authentication instead of SSH keys
8
Step 8

LXC Environment Setup

Sub-step 1

Connect to LXC container

Comment: ssh lxc-107
8
Step 8

LXC Environment Setup

Sub-step 2

Update system packages

Comment: apt update && apt upgrade -y
8
Step 8

LXC Environment Setup

Sub-step 3

Install Python and pip

Comment: apt install python3 python3-pip python3-venv -y
8
Step 8

LXC Environment Setup

Sub-step 4

Install Nginx

Comment: apt install nginx -y
8
Step 8

LXC Environment Setup

Sub-step 5

Install Git

Comment: apt install git -y
9
Step 9

Django Deployment

Sub-step 1

Open powershell as admin

Comment: ssh lxc-107
9
Step 9

Django Deployment

Sub-step 2

Create project directory

Comment: mkdir /var/www/DjFull107
9
Step 9

Django Deployment

Sub-step 3

Generate SSH key pair

Comment: ssh-keygen -t ed25519 -C 'lo.miniuk@gmail.com' -f ~/.ssh/Clone_To_LXC107
9
Step 9

Django Deployment

Sub-step 4

Update knowledge site

Comment: Document the SSH key generation process and update deployment knowledge base
9
Step 9

Django Deployment

Sub-step 5

Start SSH agent

Comment: eval "$(ssh-agent -s)"
9
Step 9

Django Deployment

Sub-step 6

Add SSH key to agent

Comment: ssh-add ~/.ssh/Clone_To_LXC107
9
Step 9

Django Deployment

Sub-step 7

Check displayed keys

Comment: ssh-add -l
9
Step 9

Django Deployment

Sub-step 8

Display public key

Comment: cat ~/.ssh/Clone_To_LXC107.pub
9
Step 9

Django Deployment

Sub-step 9

Add SSH key to GitHub

Comment: Copy public key and add to GitHub Settings > SSH and GPG keys 📖 See detailed SSH and GPG Keys setup guide in Setup Files page
9
Step 9

Django Deployment

Sub-step 10

Test SSH connection .. must be sucess ❤️

Comment: ssh -T git@github.com
9
Step 9

Django Deployment

Sub-step 11

Clone GitHub repository

Comment: git clone git@github.com:HappyMinsker/DjFull107.git /var/www/DjFull107
9
Step 9

Django Deployment

Sub-step 12

Navigate to project directory

Comment: cd /var/www/DjFull107
9
Step 9

Django Deployment

Sub-step 13

Create virtual environment

Comment: python3 -m venv venv
9
Step 9

Django Deployment

Sub-step 14

Activate virtual environment

Comment: source venv/bin/activate
9
Step 9

Django Deployment

Sub-step 15

Install requirements: Gunicorn, Postgres ...

Comment: pip install -r requirements.txt
9
Step 9

Django Deployment

Sub-step 16

Configure SSH agent auto-start

Comment: Edit ~/.bashrc and add SSH agent configuration at the end:

View .bashrc Configuration Guide
9
Step 9

Django Deployment

Sub-step 17

Save and reload bashrc

Comment: Save file (Ctrl+X, Y, Enter) then reload: source ~/.bashrc
9
Step 9

Django Deployment

Sub-step 18

Verify SSH agent auto-start

Comment: Check if agent is running: ssh-add -l (should show Clone_To_LXC107 key)
10
Step 10

Database Setup

Sub-step 1

Install PostgreSQL

Comment: apt install postgresql postgresql-contrib -y
10
Step 10

Database Setup

Sub-step 2

Switch to postgres user

Comment: sudo -u postgres psql
10
Step 10

Database Setup

Sub-step 3

Create database

Comment: CREATE DATABASE django_db;
10
Step 10

Database Setup

Sub-step 4

Create database user

Comment: CREATE USER django_user WITH PASSWORD 'your_password';
10
Step 10

Database Setup

Sub-step 5

Grant privileges

Comment: GRANT ALL PRIVILEGES ON DATABASE django_db TO django_user;
10
Step 10

Database Setup

Sub-step 6

Exit PostgreSQL

Comment: \q
11
Step 11

Django Configuration

Sub-step 1

Check settings_production.py

Comment: Edit settings_production.py to configure production settings
Setup File Available: View Configuration
11
Step 11

Django Configuration

Sub-step 2

Remove settings.py

Comment: Remove the original settings.py file to avoid conflicts: rm /var/www/DjFull107/DjFull107/settings.py
11
Step 11

Django Configuration

Sub-step 3

Move settings_production.py to settings.py

Comment: Rename settings_production.py to settings.py for production use: mv /var/www/DjFull107/DjFull107/settings_production.py /var/www/DjFull107/DjFull107/settings.py
11
Step 11

Django Configuration

Sub-step 4

Check settings

Comment: cd /var/www/DjFull107/ && python3 -c "from DjFull107 import settings; print('Settings imported successfully')"
11
Step 11

Django Configuration

Sub-step 5

Set DEBUG = False

Comment: Change DEBUG = True to DEBUG = False in settings.py
11
Step 11

Django Configuration

Sub-step 6

Set ALLOWED_HOSTS to IP/domain

Comment: Add server IP/domain to ALLOWED_HOSTS in settings.py
11
Step 11

Django Configuration

Sub-step 7

Configure PostgreSQL database

Comment: Update DATABASES setting to use PostgreSQL instead of SQLite
11
Step 11

Django Configuration

Sub-step 8

Set production SECRET_KEY

Comment: Generate and set a new SECRET_KEY for production
11
Step 11

Django Configuration

Sub-step 9

Configure static files for production

Comment: Ensure STATIC_ROOT and STATICFILES_DIRS are properly configured
11
Step 11

Django Configuration

Sub-step 10

Run migrations

Comment: python manage.py migrate
11
Step 11

Django Configuration

Sub-step 11

Collect static files

Comment: python manage.py collectstatic >> 128 static files copied to '/var/www/DjFull107/staticfiles'.
11
Step 11

Django Configuration

Sub-step 12

Create superuser .. and update Login.xlsx

Comment: python manage.py createsuperuser
11
Step 11

Django Configuration

Sub-step 13

Test Django server

Comment: python manage.py runserver 0.0.0.0:8000
12
Step 12

Gunicorn Setup

Sub-step 1

Create Gunicorn service file

Comment: nano /etc/systemd/system/gunicorn.service
Setup File Available: View Configuration
12
Step 12

Gunicorn Setup

Sub-step 2

Configure Gunicorn service

Comment: Add this configuration
12
Step 12

Gunicorn Setup

Sub-step 3

Reload systemd daemon

Comment: systemctl daemon-reload
12
Step 12

Gunicorn Setup

Sub-step 4

Enable Gunicorn service

Comment: systemctl enable gunicorn
12
Step 12

Gunicorn Setup

Sub-step 5

Start Gunicorn service

Comment: systemctl start gunicorn
12
Step 12

Gunicorn Setup

Sub-step 6

Check Gunicorn status

Comment: systemctl status gunicorn
12
Step 12

Gunicorn Setup

Sub-step 7

Restart & logs

Comment: systemctl restart gunicorn && journalctl -u gunicorn -n 50 --no-pager
13
Step 13

Nginx Configuration

Sub-step 1

Create Nginx configuration file

Comment: nano /etc/nginx/sites-available/DjFull107
Setup File Available: View Configuration
13
Step 13

Nginx Configuration

Sub-step 2

Remove default site

Comment: rm /etc/nginx/sites-enabled/default
13
Step 13

Nginx Configuration

Sub-step 3

Verify proxy/static config

Comment: Ensure proxy_pass http://127.0.0.1:8000; set proxy headers; add location /static/ pointing to /var/www/DjFull107/staticfiles
13
Step 13

Nginx Configuration

Sub-step 4

Enable Nginx site

Comment: ln -s /etc/nginx/sites-available/DjFull107 /etc/nginx/sites-enabled/
13
Step 13

Nginx Configuration

Sub-step 5

Inspect effective config and enabled sites

Comment: sudo nginx -T | sed -n '1,200p' | grep -E "server_name|listen|sites-enabled" ls -l /etc/nginx/sites-enabled/
Setup File Available: View Configuration
13
Step 13

Nginx Configuration

Sub-step 6

Test Nginx configuration

Comment: nginx -t
13
Step 13

Nginx Configuration

Sub-step 7

Restart Nginx

Comment: systemctl restart nginx
14
Step 14

Firewall Configuration

Sub-step 1

Allow HTTP traffic

Comment: ufw allow 80
14
Step 14

Firewall Configuration

Sub-step 2

Allow HTTPS traffic

Comment: ufw allow 443
14
Step 14

Firewall Configuration

Sub-step 3

Allow SSH traffic

Comment: ufw allow ssh
14
Step 14

Firewall Configuration

Sub-step 4

Enable firewall

Comment: ufw enable
14
Step 14

Firewall Configuration

Sub-step 5

Display active firewall rules

Comment: ufw status verbose
15
Step 15

SSL Certificate

Sub-step 1

Install Certbot

Comment: apt install certbot python3-certbot-nginx -y
15
Step 15

SSL Certificate

Sub-step 2

Obtain SSL certificate

Comment: certbot --nginx -d yourdomain.com
16
Step 16

Final Testing

Sub-step 1

Test website locally

Comment: curl http://localhost
16
Step 16

Final Testing

Sub-step 2

Test website externally

Comment: Visit your domain in browser: http://192.168.1.27/
16
Step 16

Final Testing

Sub-step 3

Test admin interface and connect

Comment: Visit yourdomain.com/admin
16
Step 16

Final Testing

Sub-step 4

Check logs for errors

Comment: journalctl -u gunicorn
17
Step 17

CI/CD Setup

Sub-step 1

Setup SSH key

SSH Key Setup Required: View SSH Key Setup Guide
Comment: Ensure GithubToLXC SSH key is generated and added to authorized_keys on LXC server
17
Step 17

CI/CD Setup

Sub-step 2

Create GitHub Actions workflow

Comment: Create .github/workflows/deploy.yml file in your project
Setup File Available: View Configuration
17
Step 17

CI/CD Setup

Sub-step 3

Add GitHub Secrets for automated deployment

Comment: Go to GitHub repository Settings > Secrets and variables > Actions. Add: HOST[91.149.187.178], USERNAME[root], SSH_KEY[GithubToLXC private key], PORT[40522]
17
Step 17

CI/CD Setup

Sub-step 4

Run the Test Workflow

Comment: Execute .github/workflows/test-ssh.yml to verify SSH connection
Setup File Available: View Configuration
17
Step 17

CI/CD Setup

Sub-step 5

Test automated deployment

Comment: Push a small change to GitHub main branch. GitHub Actions will automatically deploy to your server using deploy.yml workflow