A monolithic Django project with HTMX, Alpine.js, and Bootstrap.
-
Clone the repository and create a virtual environment:
git clone <repository-url> cd ce-tracking python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install Python dependencies:
pip install -r requirements.txt
-
Set up environment variables:
- Copy the
.env.examplefile to.env. - Generate a new
SECRET_keyand update the.envfile.
- Copy the
-
Run database migrations:
python manage.py migrate
- Start the Django development server:
- In a terminal, run:
python manage.py runserver
- In a terminal, run:
The application will be available at http://127.0.0.1:8000/.
The production deployment at BNL runs gunicorn under systemd, fronted by Apache as a reverse proxy.
Example /etc/systemd/system/cets.service:
[Unit]
Description=gunicorn daemon for cets
After=network.target
[Service]
User=www-data
Group=www-data
RuntimeDirectory=cets
WorkingDirectory=/path/to/cets
ExecStart=/path/to/cets/venv/bin/gunicorn \
--access-logfile /path/to/cets/tmp/gunicorn.log \
--workers 3 \
--bind unix:/run/cets/cets.sock \
cets.wsgi:application
[Install]
WantedBy=multi-user.targetInside the SSL <VirtualHost>:
ProxyPass /cets/ unix:/run/cets/cets.sock|http://localhost/
ProxyPassReverse /cets/ http://localhost/
RequestHeader set X-Forwarded-Proto "https"Set FORCE_SCRIPT_NAME=/cets in .env so Django generates URLs under the prefix.
On the server, after pushing to main:
git pull
pip install -r requirements.txt
python manage.py migrate
echo yes | python manage.py collectstatic
sudo systemctl restart cets.service