The project will explore traditional and qualitative scoring assessments of “risk/resiliency factors” associated with regional crisis preparedness and demonstrate how actionable steps in community engagement can create a different portrait of resiliency. Stories will engage examples of communities in distinct regions across Oregon facing knowable challenges in the event of a major earthquake.
- PostgresSQL
- PostgresSQL in Django requires psycopg2 (but maybe we end up bypassing this or something with PostGIS?)
- PostresSQL
- GeoDjango has other dependencies. See this more complete list of required and optional additions.
Commands indicated are always just python
but on some systems you might need
to use python3
in order to use a specific python version. If so, other commands
such as pip
have a pip3
equivalent.
Use whichever base command is appropriate for your environment.
Set up a virtual environment so that you can freely install python modules without worrying about overwriting globally installed versions. It's easy!
pip install virtualenv
- Move to the project directory (e.g.
/Applications/MAMP/htdocs/cascadia
). virtualenv venv –no-site-packages
(doesn't need to be venv, just remember what you pick)- Wait for things to happen.
source venv/bin/activate
(typedeactivate
to leave)pip install -r requirements.txt
to automatically install whatever we have in our requirements.txt.
- If you are in python3+, the wsgi install will fail. But that's okay, because you won't need it in python3. Just remove it from your local copy of the text file.
Included is an app called World that was used to initially figure out how GeoDjango works. "Real" work will probably be taking place in another app written slightly better and with all of the datasets modelled better.
- Postgres version: 9.4
- Python version: 3.4
This assumes 'python' is the command configured to run the correct python version.
- Set up an environment variable
DJANGO_SECRET_KEY
to whatever you want to set it to.- See http://techblog.leosoto.com/django-secretkey-generation/ for an example approach.
- On Max/Linux:
export DJANGO_SECRET_KEY="gibberishrandomstring"
Note: This assumes you've got Postgres with PostGIS installed, which can be a challenge on its own!
- Clone repo.
- Create a Postgres database on the Postgres server.
- Set up an environment variable
DATABASE_URL
that will be used by the Djando Database URL app to load our databse.
- example on Mac/Linux:
export DATABASE_URL="postgres://USER:PASSWORD@HOST:PORT/NAME"
- Run
python manage.py migrate
to initialize the database's structure. - Unzip the TsunamiEvacuationZones_2013.zip and TM_WORLD_BORDERS-0.3.zip into world/data
- Start a python shell with
python manage.py shell
- Type
from world import load
and thenload.run()
to import the shapefile data into the DB - Type
exit()
to exit the shell.
On Linux/Mac, as soon as you close your shell you lose those nice complicated database urls.
Save them to your .bash_profile
or equivalent.
python manage.py createsuperuser
python manage.py runserver
(or configure another webserver) and visit http://server.ip/admin and log in with new user.- Should see a list of content. Don't try to edit any DOGAMI data directly; those shapes are so complex with so many points that it's a guaranteed browser crash/freeze.
foreman start
- Any errors that pop up are probably from missing modules or missing environmental variables. Read the errors!