This is a simple website that demonstrates web development using Django and Bootstrap and one that can be replicated in various contexts such as personal portfolio and company websites. There is an accompanying free video tutorial thread for the approach used in writing the code and testing its working. It can be accessed here.
This project components include Git, Docker, Python, Django and PostgreSQL therefore here is a list of their installation instructions.
- Git - Most common version control system.
- Docker Desktop Windows - Software for handling development operations (DevOps). Installs Docker CLI, Docker Compose etc.
- Docker Desktop Linux - Installs Docker CLI, Docker Compose etc.
- Postgres - Database leveraged in this project. Version referenced in docker-compose.yml
- Python - Core language used in this project. Version referenced in the Dockerfile
- Django - Python web development framework for developers with deadlines. Version referenced in Pipfile
The project dependencies specific to Python include: pipenv, django, psycopg2-binary, crispy-bootstrap5, django-allauth, django-ckeditor, pip, whitenoise, pillow and Pipfile lists them.
To launch the project, follow the following steps.
- Install Git, Python with Pipenv (Pip can also be used), and Docker. Take note of Windows pre-requisites and Linux pre-requisites of installing Docker priorto proceeding.
- Clone this project using
git clone
command.git clone https://github.com/jkariukidev/my-demo-website.git
- Navigate into the cloned project folder and using a terminal/shell or otherwise, rename the .env_dev.sample
or env_prod.sample to
.env_dev
in development or.env_prod
in production to be recognized by docker compose. - Edit the environment variables as you please and ensure you do not share passwords and secure keys with the public. The env variables include:
SECRET_KEY
- Django cryptography key leveraged in reference.POSTGRES_DB
- Postgres database name. postgresql reference, docker referencePOSTGRES_USER
- Optional variable used together withPOSTGRES_PASSWORD
that sets a user and password.POSTGRES_PASSWORD
- Mandatory variable used to set a superuser password. Must not be empty.DEBUG
- Variable used in fixing issues in development (hence set toFalse
)environment and should never be set toTrue
in production. Reference
- Run the docker services for this project using compose in development environment.
OR to run in a detached mode (without seeing the logs) .ie. in the background
docker compose -f docker-compose-dev.yml up
docker compose -f docker-compose-dev.yml up -d
- Run the docker services for this project using compose in production environment.
OR to run in a detached mode (without seeing the logs) .ie. in the background
docker compose -f docker-compose-prod.yml up
docker compose -f docker-compose-prod.yml up -d
- Propagate models into your database schema using the migrate command. Note
that this command is being run inside the docker web container. Refer for more on exec docker command.
similarly, in production
docker compose -f docker-compose-dev.yml exec web python manage.py migrate
docker compose -f docker-compose-dev.yml exec web python manage.py migrate
- To check the logs you can make use of
docker compose -f docker-compose-dev.yml logs
ordocker compose -f docker-compose-dev.yml logs -f
to continue watching the log file and its print out. - In development, access the website in (HTTP) http://localhost:8000 while in production, (HTTPS) https://localhost
- Please check the live website at https://mywebsite-jkariukidev.herokuapp.com/
- Developing and deploying a modern website
- Personal blog article management
- User account management including authentication and authorization extensibility.
- Emailing and web form security
If you want to contribute to a project and make it better, your help is very welcome. Contributing is also a great way to learn more about social coding on GitHub, new technologies and their ecosystems and how to make constructive, helpful bug reports, feature requests and the noblest of all contributions: a good, clean pull request.
Look for a project's contribution instructions. If there are succinct, please follow them.
-
Create a personal fork of the project on GitHub by clicking here.
-
Clone the fork on your local machine. Your remote repo on GitHub is called
origin
. -
Add the original repository as a remote called
upstream
. -
If you created your fork a while ago be sure to pull upstream changes into your local repository.
-
Create a new branch to work on! Branch from
develop
if it exists, else frommaster
. -
Implement/fix your feature, comment your code.
-
Follow the code style of the project, including indentation.
-
If the project has tests run them!
-
Write or adapt tests as needed.
-
Add or change the documentation as needed.
-
Squash your commits into a single commit with git's interactive rebase. Create a new branch if necessary.
-
Push your branch to your fork on GitHub, the remote
origin
. -
From your fork open a pull request in the correct branch. Target the project's
develop
branch if there is one, else go formaster
! -
If the maintainer requests further changes just push them to your branch. The PR will be updated automatically.
-
Once the pull request is approved and merged you can pull the changes from
upstream
to your local repo and delete your extra branch(es).
And last but not least: Always write your commit messages in the present tense. Your commit message should describe what the commit, when applied, does to the code โ not what you did to the code.
Following the guidelines on testing Python projects using:
- Implementation of Django Unittest in this test.py file. Run the tests using
docker compose -f docker-compose-dev.yml exec web python manage.py test
- Tox
- Django testing tools
Use the production configuration in deploying into a public server. Following the guidelines on deployment in tutorial demo:
If you have any questions you can contact me!