Skip to content

skovranek/dojango

Repository files navigation

DoJango

Do + Django = DoJango

View DoJango on Heroku

License: LGPL v3

Table of Contents

  1. Overview
  2. Features
  3. Download/Install With Heroku
  4. Configure and Implement With Heroku
  5. Run on Localhost
  6. Customization
  7. Dependencies
  8. Contact
  9. Contribute
  10. License

Overview

DoJango is yet another todo list web app. More specifically, DoJango is a Python CRUD web app built with the Django framework, hosted on Heroku with a PostgreSQL database. I challenged myself to build a simple web app using Python. This project demonstrates knowledge of Python, Django and backend development.

Features

DoJango's features and how to use them are explained on its landing page: DoJango Introduction

  • Add, Edit and Delete Models: Categories/Projects, Tasks, SubTasks, Counters.
  • "Today's Tasks": See todos listed by priority and due date.
  • "Projects": See tasks per project.
  • "Deadlines": See tasks listed by due date.
  • "Previous # Days": See days with tasks.
  • "Library": Find all categories, projects, tasks or unfinished tasks.
  • "Archive": See todo lists by date.
  • Users are distinguished by browser session id.

Note Previously, I implemented user accounts but I decided that registering an account was an unnecessary burden to ask of potential users of such a straightforward app.

Download/Install with Heroku

  1. Fork this repo, then clone your forked repo on your local machine: GitHub Fork A Repo
$ gh repo fork skovranek/dojango --clone=true
  • Or you may use the 'Fork' button above, then clone your forked repo: Browser
$ git clone https://github.com/YOUR-USERNAME/dojango
  1. Create and verify a Heroku account: Heroku Sign Up & Heroku Account Verification

  2. Install the Heroku CLI, verify the version, and then login: Heroku CLI Installation

$ brew tap heroku/brew && brew install heroku

$ heroku --version

$ heroku login

Configure and Implement with Heroku

  1. Subscribe to the Ecos Dynos Plan: Heroku Ecos Dyno Hours

  2. Using the Heroku CLI, create a Heroku remote for the existing app in the forked repo on your local machine. (Do not deploy yet): Deploying to Heroku with Git

$ heroku git:remote -a your-app-name
  1. In the 'main/settings.py' file, change the 'ALLOWED_HOSTS' setting to include your app's web address.
ALLOWED_HOSTS = ['your-app-name-2bea5c2d6d6c.herokuapp.com']
  1. Add your own secret key to the configuration variables of your app: Heroku Config Vars
$ heroku config:set DJANGO_SECRET_KEY=your_unique_secret_key
  1. You may also choose to enable debug mode while deploying and testing. Change it to an empty string to disable debug mode later.
$ heroku config:set DJANGO_DEBUG=True
  1. Create a database for your app by subscribing to the Heroku PostgreSQL Mini plan, for an additional cost: Provision Heroku PostgreSQL Mini
$ heroku addons:create heroku-postgresql:mini
  1. Prepare the database for your app.
$ heroku run python manage.py makemigrations

$ heroku run python manage.py migrate
  1. Create an administrator account. Follow the prompts.
$ heroku run python manage.py createsuperuser
  1. Now you may deploy to Heroku with Git, following the rest of the instructions from the link in Step 2.
$ git push heroku main
  1. Check the Heroku log to ensure the app is online and configured correctly.
$ heroku logs --tail

If you run into any issues, you may check these articles for additional guidance:

Getting Started with Python on Heroku

Deploying Django on Heroku

Medium Article - Deploying Django App to Heroku: Full Guide

Run on Localhost

Django provides a developmental server you may run on localhost, which is free, unlike Heroku.

  1. Change the configuration by making these changes in the 'main/settings.py' file: Django Settings
DEBUG = bool(os.environ.get('DJANGO_DEBUG', True))

# do not push or deploy this secret key to production.
SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', 'q!m3b=%0d1v9m_m+2ygv-o*+3@w0a3vutzuy(ol*$()na10am)')

ALLOWED_HOSTS = ['127.0.0.1']

SECURE_SSL_REDIRECT = False
SESSION_COOKIE_SECURE = False
CSRF_COOKIE_SECURE = False
SECURE_PROXY_SSL_HEADER = None

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.sqlite3",
        "NAME": "dojango_database",
    }
}
  1. Create a virtual environment: Python.org Virtual Environment
$ python3 -m venv env
  1. Activate virtual environment: Python.org Activate
$ source env/bin/activate

Note

When you want to turn off the virtual environment later:

$ deactivate
  1. Install dependencies: Python.org 'requirements.txt'
$ python3 -m pip install -r requirements.txt
  1. Prepare the database: Django Workflow
$ python3 manage.py makemigrations
$ python3 manage.py migrate
  1. Create a 'superuser' admin account: Django Admin User
$ python3 manage.py createsuperuser
  1. Ensure your browser's security settings permit 'http' traffic. Modern browsers automatically redirect requests through 'https' instead of 'http'. This can be a headache for developers who just want to test a local server. Be sure to change your browser's security settings back to your preferences when you are done.

  2. Start the server: Django 'runserver'

$ python3 manage.py runserver
  1. Use your browser to check your server by navigating to the default localhost address, 'http://127.0.0.1:8000'. This is not a production server and should only be used for development and testing.

Customization

You may customize DoJango's design by modifying the CSS style in the todo_app/static/style.css file.

Dependencies

runtime.txt

python-3.12.0

requirements.txt

django>=4.2,<5.0
gunicorn>=21.2,<22.0
dj-database-url>=2.0,<3.0
whitenoise[brotli]>=6.0,<7.0
psycopg; sys_platform == "linux"
psycopg[binary]; sys_platform != "linux"

Contact

Questions, issues or suggestions: mattjskov at gmail.com

Contribute

This project is just a proof of concept and I consider it finished.

License

License: LGPL v3

DoJango is released under the GNU Lesser General Public License v3.0.