A minimalist, easy-to-use digital planner, designed with the power of a digital organizer, and the simplicity of a paper planner.
This app is powered by Django and uses a PostgreSQL database. Originally developed as a capstone project in the Pybites Python Developer Mindset (PDM) Program, this project is under active development.
Copyright © 2024 Anschel Burk. All rights not explicitly granted in this project's license reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See this project's LICENSE.txt file for the specific language governing permissions and limitations under the License.
HTTPS:
git clone https://github.com/anschelburk/Math-Homework.git
SSH:
git clone git@github.com:anschelburk/Math-Homework.git
Windows (PowerShell):
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
Linux & MacOS:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Please Note: When you create this PostgreSQL database, you will be prompted to create a username, password, and name for the database. Please keep this information - you will need it later (in Step 4b) in order for this app to communicate with your local database.
This app uses the python-decouple
library to manage environment variables, using a local .env
file which must be configured prior to use. To do this, follow the instructions below.
Locate the provided .env_template
in the project directory, and copy it. Name the copy .env
.
Open the new .env
file, where you will find four lines of text:
SECRET_KEY=
DATABASE_URL=
ALLOWED_HOSTS=[]
DEBUG=
SECRET_KEY
, ALLOWED_HOSTS
, and DEBUG
are Django settings, which must be manually configured prior to use. (Instructions are included below.)
DATABASE_URL
is the URL for the PostgreSQL database you created in Step 3.
Here's how to configure each of these environment variables.
SECRET_KEY
environment variable.Django uses this setting to provide cryptographic signing. It should be set to a unique, unpredictable value, which Django will generate for you. (For more information on this setting, please see Django's documentation.)
Here's how to set this up.
Open a terminal window in this project's directory. Make sure the virtual environment is running, and all this project's dependencies have been installed. (If you haven't done these things yet, please see Step 2.)
In that terminal window, activate the Python interactive console:
Windows (PowerShell):
python
Linux/MacOS:
python3
Generate a new Django secret key using the following terminal commands:
Python Interactive Console (for all operating systems):
from django.core.management.utils import get_random_secret_key
print(get_random_secret_key())
Copy that secret key, and paste it as a string next to SECRET_KEY =
in your local .env
file.
For example, if Django generates the following secret key for you:
abcdefghijklmnop1234567890
Then the SECRET_KEY
line of your .env
file should look like this:
SECRET_KEY='abcdefghijklmnop1234567890'
Finally, exit the Python interactive console using the following command.
Python Interactive Console (for all operating systems):
quit()
DATABASE_URL
environment variable.This project uses a PostgreSQL database, which you set up in Step 3. In order for this app to communicate with that database, you need to input the database's URL into as an environment variable in your local repo's .env
file.
In order to do that: you'll need the following information:
localhost
or 127.0.0.1
.5432
.Using this information, construct your local database's URL using the following structure:
postgres://username:password@host:port/databasename
For example, let's say your database information looked like this:
Then your database's URL would look like this:
postgres://john:defaultpass@localhost:5432/sampledb
Once you have your database's URL, paste it into your .env
file. The example above would look like this:
DATABASE_URL=postgres://john:defaultpass@localhost:5432/sampledb
ALLOWED_HOSTS
environment variable.Django uses the ALLOWED_HOSTS
setting as a security measure to clarify which host/domain names that this Django project can serve. (For more information on this setting, please see Django's documentation.)
This setting is incredibly easy to configure. Simply copy the HOST you used in your database URL in Step 4b, and paste it in your local repo's .env
file.
For example, if the HOST from your database URL was localhost
, then the ALLOWED_HOSTS
environment variable in this project's .env
file should look like this:
ALLOWED_HOSTS=localhost
Optional: If you would like to allow multiple hosts, simply add them as a list to the ALLOWED_HOSTS
variable in your local repo's .env
file. For example, all three of the following would be valid:
ALLOWED_HOSTS=[localhost, 127.0.0.1]
ALLOWED_HOSTS=(localhost, 127.0.0.1)
ALLOWED_HOSTS=localhost, 127.0.0.1
DEBUG
environment variable.Django uses a setting, DEBUG
, to toggle debug mode on and off. This project abstracts that setting as an environment variable. (For more information on Django's DEBUG
setting, please see their documentation.)
This setting should typically be set to False
- meaning, in other words, that debug mode is turned off.
This means that in your local repo's .env
file, the DEBUG
environment variable should look like this:
DEBUG=False
If at any point you would like to enable debug mode, simply toggle that value to True
.
Congratulations! Now that you've configured the environment variables, you're nearly done. The last two steps are quick and easy.
Before you can use your PostgreSQL database, you need to migrate the this project's database model and initial data. Django makes this very easy.
Please Note: The first step - loaddata initial_lists
- loads the initial information used to populate the to-do lists in this organizer, from a static fixture included in this repo: /mysite/planner/fixtures/initial_lists.json
.
From the project directory, navigate to the mysite
directory, and then run the following terminal commands to load and migrate the necessary models & data your PostgreSQL database:
PowerShell (Windows):
cd mysite
python manage.py loaddata initial_lists
python manage.py makemigrations
python manage.py migrate
Linux & MacOS:
cd mysite
python3 manage.py loaddata initial_lists
python3 manage.py makemigrations
python3 manage.py migrate
From the project directory, navigate to the mysite
directory, and then use Django to run the project on a local server.
Note: when you do this, a server log will automatically appear in your terminal window. To stop running the project (on any operating system), simply go to this server log and type CTRL
C
at any time.
Windows (PowerShell):
cd mysite
python manage.py runserver
Linux & MacOS:
cd mysite
python3 manage.py runserver
Enjoy!