Do + Django = DoJango
- Overview
- Features
- Download/Install With Heroku
- Configure and Implement With Heroku
- Run on Localhost
- Customization
- Dependencies
- Contact
- Contribute
- License
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.
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.
- Fork this repo, then clone your forked repo on your local machine: GitHub Fork A Repo
- You may use the GitHub CLI: GitHub CLI
$ 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
-
Create and verify a Heroku account: Heroku Sign Up & Heroku Account Verification
-
Install the Heroku CLI, verify the version, and then login: Heroku CLI Installation
$ brew tap heroku/brew && brew install heroku
$ heroku --version
$ heroku login
-
Subscribe to the Ecos Dynos Plan: Heroku Ecos Dyno Hours
-
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
- 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']
- 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
- 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
- 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
- Prepare the database for your app.
$ heroku run python manage.py makemigrations
$ heroku run python manage.py migrate
- Create an administrator account. Follow the prompts.
$ heroku run python manage.py createsuperuser
- Now you may deploy to Heroku with Git, following the rest of the instructions from the link in Step 2.
$ git push heroku main
- 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
Medium Article - Deploying Django App to Heroku: Full Guide
Django provides a developmental server you may run on localhost, which is free, unlike Heroku.
- 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",
}
}
- Create a virtual environment: Python.org Virtual Environment
$ python3 -m venv env
- Activate virtual environment: Python.org Activate
$ source env/bin/activate
Note
When you want to turn off the virtual environment later:
$ deactivate
- Install dependencies: Python.org 'requirements.txt'
$ python3 -m pip install -r requirements.txt
- Prepare the database: Django Workflow
$ python3 manage.py makemigrations
$ python3 manage.py migrate
- Create a 'superuser' admin account: Django Admin User
$ python3 manage.py createsuperuser
-
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.
-
Start the server: Django 'runserver'
$ python3 manage.py runserver
- 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.
You may customize DoJango's design by modifying the CSS style in the todo_app/static/style.css
file.
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"
Questions, issues or suggestions: mattjskov at gmail.com
This project is just a proof of concept and I consider it finished.
DoJango is released under the GNU Lesser General Public License v3.0.