The goal of this project is:
- to demonstrate how to use flask for easy web development
- show how it simplifies development through it's MVT Design Pattern. This leads to code being easy to change and to understand.
-
Copy requirements.txt file from this repo and add to your directory
-
Set up virtual enviroment and install needed applications.
python3 -m venv venv
# if venv already exists
# source venv/bin/activate
pip install -r requirements.txt
- Set up custom project name
# initial project creation
django-admin startproject <site>
#where site here is webapp and generates webapp directory
- May need to generate the staticfiles directory using:
python manage.py collectstatic
- Customize port to allow external IPs if desired By default the server runs on localhost to further adjust this so that it runs on external ip and can be access from a different computer you need to adjust.
diff --git a/webapp/webapp/settings.py b/webapp/webapp/settings.py
index 70bc93e..fc91c56 100644
--- a/webapp/webapp/settings.py
+++ b/webapp/webapp/settings.py
@@ -26,7 +26,7 @@ SECRET_KEY = "django-insecure-9pwvyr78pxz#c2)rq5v@7r(n9z&v$f5o
gbxq*z3@*^u&$ml5q2
DEBUG = True
# optional fill in IP here as such
-ALLOWED_HOSTS = [ ]
+ALLOWED_HOSTS = [ 'A.B.C.D' ]
This will allow you run the server as such: From the directory that contains manage.py do:
python manage.py runserver A.B.C.D:8001
python manage.py createsuperuser
- Ensure data is visible for admin login by adding this to admin.py
admin.site.register(<NewTable>)
Update the database by doing the following:
python manage.py createmigrations <NewTable>
python manage.py migrate
- Ensure Database is initialized
python manage.py shell
- Login as admin to validate that the new Table exists