Django E-Commerce Webshop
This project is a full-featured e-commerce web application built using Django and deployed with Docker on a V-Server.
Introduction
This Django-based webshop allows users to register, log in, browse products, apply filters, and view product details. The system supports an admin panel where shop owners can manage products, orders, and users.
Table of Contents
Quickstart
- Install dependencies:
sudo apt update && sudo apt install -y docker.io git - Clone the repository:
git clone -b development git@github.com:BenjaminTietz/baby-tools-shop.git cd baby-tools-shop - Generate and configure the .env file:
The environment file will be created automatically from env.template. Adjust the values to match your setup:cp .envtemplate .env nano .env - Build the Docker image:
docker build -t baby-tools-shop . - Start the container:
docker run -d -p 8025:8025 --env-file .env --name baby-tools-container baby-tools-shop - Access the webshop:
http://<your-server-ip>:8025/ - Log in to the admin panel:
http://<your-server-ip>:8025/admin
Step 7 sends the Django admin password over plain HTTP, and the session cookie issued afterwards travels unencrypted with every following request. Do not expose the admin panel this way on a server that is reachable from the internet. Instead: publish the container port on the loopback interface only (docker run -p 127.0.0.1:8025:8025 …), put a reverse proxy (nginx, Caddy, Traefik) in front of it and let the proxy terminate TLS with a certificate from a public CA (Let's Encrypt). Django then needs SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") so it recognises the forwarded requests as secure, plus SECURE_SSL_REDIRECT, SESSION_COOKIE_SECURE and CSRF_COOKIE_SECURE set to True.
Usage
Environment Variables
The application uses environment variables to configure certain aspects of the system. These can be set in the .env file:
ALLOWED_HOSTS=["localhost", "127.0.0.1", "<your-server-ip>"]
DEBUG=True
DJANGO_PRODUCTION=False
DJANGO_SUPERUSER_USERNAME=admin
DJANGO_SUPERUSER_EMAIL=admin@example.com
DJANGO_SUPERUSER_PASSWORD=adminpassword
These are local development values, not deployment values. DEBUG=True makes Django return full tracebacks including settings and local variables to anyone who triggers an error — the Django deployment checklist is explicit that a site must never go into production with DEBUG turned on. adminpassword is a placeholder; replace it before the superuser is created, and keep the .env file out of version control.
Managing the Database
Run migrations manually inside the container if needed:
docker exec -it baby-tools-container python manage.py migrate
To create a new Django superuser manually:
docker exec -it baby-tools-container python manage.py createsuperuser
Collecting Static Files
If you update static files and need to collect them again, run:
docker exec -it baby-tools-container python manage.py collectstatic --noinput
Stopping and Restarting the Container
To stop the container:
docker stop baby-tools-container
To restart it:
docker start baby-tools-container
To remove the container completely:
docker rm baby-tools-container
To rebuild and restart:
docker build -t baby-tools-shop .
docker run -d -p 8025:8025 --env-file .env --name baby-tools-container baby-tools-shop
Requirements
- A V-Server running Ubuntu/Debian
- Docker
- Git
Ensure your system is up to date:
sudo apt update && sudo apt install -y docker.io git
This project is built and run with plain docker build / docker run; no Compose file is involved, so no Compose package is required.