Giter Site home page Giter Site logo

gthaka / my-demo-website-django Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jkariscodes/my-demo-website

0.0 0.0 0.0 6.7 MB

Website project demonstrating use of Django, Bootstrap and PostgreSQL in developing a fullstack website and DevOps using Docker and hosting using Heroku PaaS. https://mywebsite-jkariukidev.herokuapp.com

License: MIT License

JavaScript 79.41% Python 1.57% CSS 14.85% HTML 4.14% Dockerfile 0.02%

my-demo-website-django's Introduction

My Website Project

Description

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.

Table of Contents

Installation

This project components include Git, Docker, Python, Django and PostgreSQL therefore here is a list of their installation instructions.

Software

  • 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

Dependencies

The project dependencies specific to Python include: pipenv, django, psycopg2-binary, crispy-bootstrap5, django-allauth, django-ckeditor, pip, whitenoise, pillow and Pipfile lists them.

Procedure

To launch the project, follow the following steps.

  1. 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.
  2. Clone this project using git clone command.
    git clone https://github.com/jkariukidev/my-demo-website.git
  3. 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.
  4. 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 reference
    • POSTGRES_USER - Optional variable used together with POSTGRES_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 to False)environment and should never be set to True in production. Reference
  5. Run the docker services for this project using compose in development environment.
    docker compose -f docker-compose-dev.yml up
    
    OR to run in a detached mode (without seeing the logs) .ie. in the background
    docker compose -f docker-compose-dev.yml up -d
    
  6. Run the docker services for this project using compose in production environment.
    docker compose -f docker-compose-prod.yml up
    
    OR to run in a detached mode (without seeing the logs) .ie. in the background
    docker compose -f docker-compose-prod.yml up -d
    
  7. 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.
    docker compose -f docker-compose-dev.yml exec web python manage.py migrate
    
    similarly, in production
    docker compose -f docker-compose-dev.yml exec web python manage.py migrate
    
  8. To check the logs you can make use of docker compose -f docker-compose-dev.yml logs or docker compose -f docker-compose-dev.yml logs -f to continue watching the log file and its print out.
  9. In development, access the website in (HTTP) http://localhost:8000 while in production, (HTTPS) https://localhost
  10. Please check the live website at https://mywebsite-jkariukidev.herokuapp.com/

Usage

  • Developing and deploying a modern website
  • Personal blog article management
  • User account management including authentication and authorization extensibility.
  • Emailing and web form security

License

Contributing

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.

making 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 from master.

  • 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 for master!

  • 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.

Tests

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

Deployment

Use the production configuration in deploying into a public server. Following the guidelines on deployment in tutorial demo:

Questions

If you have any questions you can contact me!

References

my-demo-website-django's People

Contributors

jkaris avatar gthaka avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.