-
Check out code and
git checkout develop
. -
Ensure Postgres and Postgis are installed, and create a database:
$ SITENAME=buzzhire $ sudo su postgres -c "createuser -d -R -P $SITENAME" $ sudo su postgres -c "createdb -O $SITENAME $SITENAME" $ sudo su postgres -c "psql $SITENAME -c 'CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology;'"
-
Install redis, if it isn't already.
-
Create virtualenv and run
pip install -r requirements.pip
. -
The site uses django-configurations to handle settings. The simplest thing way to get the site running is to configure your local machine to use the same settings as the
Local
settings class insettings/installations.py
. However, if you want to adjust these then you should add an extra settings class toinstallations.py
, and make sure theDJANGO_CONFIGURATION
environment variable is set to the name of your class. -
Sensitive settings should be put in
settings/secret.py
, which will not be under version control. These are the minimum settings:DEFAULT_DATABASE_PASSWORD = '' # Password to local database SECRET_KEY = '' # Any random string
-
Ensure the site can send emails - this can be done by configuring the configuration you're using to send via an SMTP server, or by switching the
EMAIL_BACKEND
to'django.core.mail.backends.console.EmailBackend'
. If you're using an SMTP server,EMAIL_HOST_PASSWORD
should be included insecret.py
. -
Set up a Braintree sandbox account and add the settings to your configuration class, and
BRAINTREE_PRIVATE_KEY
tosecret.py
. -
Run
./manage.py migrate
.
cd path/to/site
workon buzzhire
(Or whatever your virtualenv is called.)./manage.py runserver
- In another terminal, run
workon buzzhire
and then./manage.py run_huey
. (This is the task queue.) - The site should now be accessible at
http://localhost:8000
.
N.B. If there are new code commits from other developers, you may need to run
the following commands before ./manage.py runserver
:
pip install -r requirements.txt
./manage.py migrate
In general, code should be committed to the develop
branch.
Before deploying, ensure Fabric is installed on your system. You will also need to ask for your public keys to be added to the BuzzHire server.
Your deployment process is then simply:
git push
your code to thedevelop
branch.fab deploy
.
Django uses a template system. Documentation is here: https://docs.djangoproject.com/en/1.8/ref/templates/language/
The templates you will be editing are under the templates
directory.
To include static files such as CSS, static images and javascript,
use the {% static %}
template tag. This will look under the static
directory for the files. Examples in templates/include/html_head.html
.
The main stylesheet is at static/css/main.less
, and the main javascript file
is at static/js/theme.js
.
Some static files are automatically compressed, and LESS files compiled,
using a tool called Django-compressor. An example of this in action
is in templates/include/html_head.html
.
- Edit
settings/project.py
and find the lineBOWER_INSTALLED_APPS
. Add the third party source to it. - Run
./manage.py bower install
locally. This will collect the third party source intocomponents/bower_components
. - Anything within
components/bower_components
can now be included in templates using the{% static %}
template tag. For examples, seetemplates/include/html_head.html
.