Professional Documents
Culture Documents
Djangochurch Developer Readthedocs Io en Latest
Djangochurch Developer Readthedocs Io en Latest
Djangochurch Developer Readthedocs Io en Latest
Documentation
Release current
Django Church
1 Overview 3
1.1 What is Django Church? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Deployment 5
2.1 Heroku . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3 Development 9
3.1 Vagrant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4 Themes 11
4.1 What themes are available? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.2 Theme installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.3 Theme customisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
i
ii
Django Church Developer Documentation, Release current
Contents:
Contents 1
Django Church Developer Documentation, Release current
2 Contents
CHAPTER 1
Overview
For end users, you may want to read the Django Church user documentation, which explains in more detail what
Django Church is.
However for developers, Django Church is a project which consists of the following applications and packages:
• Django - the website framework
• blanc-basic-assets - for file uploads
• blanc-basic-pages - for pages
• blanc-basic-news - for news/blog posts
• blanc-basic-events - for events
As well as the following themes:
• Bold
• Fresh
• Calm
• House
• Light
1.2 Requirements
1.2.1 Django
Django Church is built for the latest release of Django - currently Django 1.7.
Older versions of Django are unsupported and will not work.
1.2.2 Python
The minimum required Python version is Python 2.7, we recommend that you use the latest bugfix release.
Django Church also supports Python 3. Currently Python 3.3 is tested and supported - older version of Python 3 will
not work with all applications.
3
Django Church Developer Documentation, Release current
4 Chapter 1. Overview
CHAPTER 2
Deployment
Django Church can be deployed on host which meets the minimum requirements for the project.
If you’re unfamiliar with Django deployment, we recommend that you should read the deploying Django documenta-
tion. The Django Church deployment documentation is intended to show the basics of deployment with the Django
Church packages.
2.1 Heroku
Before deploying on Heroku, we recommend that you read the getting started with Python and getting started with
Django documentation on the Heroku dev center documentation site.
These instructions are a modified version of the getting started with Django documentation from Heroku, adjusted to
make it easier to get going with the default applications provided by Django Church.
2.1.1 Prerequisites
Note: Make sure you’re using the latest virtualenv release. If you’re using an older version, you may need to add the
--no-site-packages flag.
5
Django Church Developer Documentation, Release current
To use the new virtualenv, we need to activate it. (You must source the virtualenv environment for each terminal
session where you wish to run your app.):
$ source venv/bin/activate
Now that Django is installed, we can start the project using the Django Church template:
Note: Don’t forget the . in the middle. This tells Django to extract into the current directory, instead of putting it in
a new subdirectory.
We’ll be using the House theme for this example. If you want a different theme then please read more about themes.
Run the following commands:
$ curl -sL https://github.com/djangochurch/djangochurch-theme-house/tarball/master | tar zxv
...
x djangochurch-djangochurch-theme-house-1852fc3/templates/pages/
x djangochurch-djangochurch-theme-house-1852fc3/templates/pages/default.html
$ mv djangochurch-djangochurch-theme-house-* theme
Now that we’ve written and tested our application, we need to store the project in a Git repository.
Next, we’ll create a new git repository and save our changes.
$ git init
Initialized empty Git repository in /Users/kreitz/hellodjango/.git/
$ git add .
$ git commit -m "my django app"
[master (root-commit) 2943412] my django app
12 files changed, 676 insertions(+)
create mode 100644 .gitignore
create mode 100644 Procfile
create mode 100644 manage.py
create mode 100644 mychurch/__init__.py
6 Chapter 2. Deployment
Django Church Developer Documentation, Release current
The next step is to push the application’s repository to Heroku. First, we have to get a place to push to from Heroku.
We can do this with the heroku create command:
$ heroku create
Creating simple-spring-9999... done, stack is cedar
http://simple-spring-9999.herokuapp.com/ | git@heroku.com:simple-spring-9999.git
Git remote heroku added
This automatically added the Heroku remote for our app (git@heroku.com:simple-spring-9999.git) to
our repository. Now we can do a simple git push to deploy our application:
$ git push heroku master
Counting objects: 11, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (11/11), 4.01 KiB, done.
Total 11 (delta 0), reused 0 (delta 0)
-----> Python app detected
-----> Preparing Python runtime (python-2.7.7)
-----> Installing Setuptools (3.6)
-----> Installing Pip (1.5.6)
-----> Installing dependencies using Pip (1.5.6)
...
-----> Collecting static files
0 static files copied.
To git@heroku.com:simple-spring-9999.git
* [new branch] master -> master
The heroku run command lets you run one-off dynos. You can use this to sync the Django models with the
database schema:
$ heroku run python manage.py migrate
Running ‘python manage.py migrate‘ attached to terminal... up, run.1
Operations to perform:
Synchronize unmigrated apps: assets, admin, mptt, pages, sessions, news, events, contenttypes, auth
Apply all migrations: easy_thumbnails
Synchronizing apps without migrations:
Creating tables...
2.1. Heroku 7
Django Church Developer Documentation, Release current
You have installed Django’s auth system, and don’t have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use ’u12733’): admin
Email address: admin@example.org
Password:
Password (again):
Superuser created successfully.
As Heroku only offers an ephemeral filesystem, we need to configure a few additional settings to keep media files.
We’ll be adding a few environment variables on Heroku.
Follow the instructions on the Heroku S3 docs, and configure the environment variables:
• AWS_ACCESS_KEY_ID
• AWS_SECRET_ACCESS_KEY
• S3_BUCKET_NAME
As a quick reminder, the following command will get your environment variables setup on Heroku:
heroku config:set AWS_ACCESS_KEY_ID=xxx AWS_SECRET_ACCESS_KEY=yyy S3_BUCKET_NAME=zzz
You’ve deployed your code to Heroku, so we can now visit the app in our browser with heroku open.
$ heroku open
Opening simple-spring-9999.herokuapp.com... done
You should see the satisfying “It worked!” Django welcome page.
8 Chapter 2. Deployment
CHAPTER 3
Development
3.1 Vagrant
To get you up and running quickly and easily, a Django Church Vagrantfile is available for usage with Vagrant and
Virtualbox.
3.1.1 Prerequisites
• Installed Virtualbox.
• Installed Vagrant.
3.1.2 Mac OS X
Note: If you don’t have the OS X developer tools installed, a pop-up may appear asking you to install them. Install
the developer tools, then run the first command again.
The vagrant up command may take up to 15 minutes to run, but may take longer on slower Internet connections.
Once vagrant up has completed, the sites directory in the djangochurch-vagrant directory will contain
the 5 Django instances of Django Church, each with a different theme. By default the sites should be accessible at:
• Bold: http://127.0.0.1:5001/
• Fresh: http://127.0.0.1:5002/
9
Django Church Developer Documentation, Release current
• Calm: http://127.0.0.1:5003/
• House: http://127.0.0.1:5004/
• Light: http://127.0.0.1:5005/
The Django admin panel is accessible at /admin/, with the username and password both set to admin.
All Django instances share the same database and media directory, so any content added to one site will appear on all
other sites, allowing you to preview how your site could look with another theme.
Once you’ve finished, simply run:
$ vagrant destroy
default: Are you sure you want to destroy the ’default’ VM? [y/N] y
==> default: Forcing shutdown of VM...
==> default: Destroying VM and associated drives...
==> default: Running cleanup tasks for ’shell’ provisioner...
Then Vagrant will stop the virtual machine running the sites.
10 Chapter 3. Development
CHAPTER 4
Themes
We provide the following themes as base templates for Django Church. Each of them contains a static and
templates directory, with all the files needed for the standard Django Church applications:
• Bold
• Fresh
• Calm
• House
• Light
Simply replace house with one of the other theme names to install another theme.
If you want to change the HTML files or other static files for a theme, we recommend that you copy the file from
the theme directory into your project directory before editing it. By default Django will use templates from the site
template directory before the theme directory.
As an example, if your project was mychurch, you’d copy the original theme/templates/base.html to
mychurch/templates/base.html.
11