[Heroku retracted its free tier, therefore all my demos are unavailable until further notice.]
- Project description
- Technologies used
- Deployment
- Environment variables
- Features
- Room for improvement
- Author
This is a recruitment task for a Junior Python Developer position. The task was simple: to create a Django admin-panel-only website, with two models (Author, Song) with a many-to-many relationship between them, along with viewing and creating instances of those models in the admin panel.
The database choice was arbitrary, but with a recommendation of an in-memory version. While I believe it would make the task easier in for example Java's Spring, in Django it doesn't. I decided to take the challenge and try to run Django with an in-memory database only, and I succeeded. Every time the server is shut down, created model instances are wiped. Every time the server is started, migrations are run and the admin account is created automatically. I do realise that it is a nonstandard solution, but I still wanted to try that, since the rest of the task was straightforward.
Besides that, I implemented automated testing in a CI/CD pipeline on SemaphoreCI, along with dockerization and deployment from a container to Heroku.
- Python 3.9.12
- Django 4.0.5
- Gunicorn 20.1.0
- Docker
- SemaphoreCI
- Heroku
A) through Docker:
- Create an
.env
file basing on.env_sample_file
from the repository. - Run
docker run --env-file .env -p 8020:8020 bsski/django-music:latest
in the.env
file directory. - Access
localhost:8020
.
B) without Docker:
- Download the repository.
- Create a virtual environment.
- Run
pip install -r requirements.txt
in the directory ofrequirements.txt
. - Create an
.env
file basing on.env_sample_file
from the repository in the directory of.env_sample_file
. - Run
python manage.py runserver --noreload
in the directory ofmanage.py
. - Access
127.0.0.1:8000
.
The admin panel can be found under your chosen URL or, if you didn't set it in the .env file, the default /hidden_admin_url
.
Security through obscurity is not enough of course, but I find it a nice complementary solution.
To run this project, you have to set up the following environment variables in the .env
file (the values below are exemplary):
DJANGO_SUPERUSER_PASSWORD=TestAdminPassword
DJANGO_SUPERUSER_USERNAME=TestAdminName
DJANGO_SUPERUSER_EMAIL=TestAdmin@email.com
SECRET_KEY=TestSecretKey
ADMIN_LOGIN_URL=test_admin_login_url
PORT=8020
- two models in a many-to-many relationship (Author, Song),
- django admin panel which enables creating instances of models and viewing them,
- purely in-memory database.
Furthermore, the website is deployed on Heroku from a Docker image using a CI/CD SemaphoreCI pipeline:
Room for improvement:
- QoL features in admin panel could be added, for example sorting.