Getting started with Contentful and Django
This Django getting started guide will walk you through your first steps using Contentful within a Django application. It will provide a step-by-step guide on how to get your first entries and start using the content you create on Contentful.
Requirements
- A Heroku account
- Python 2.7+ or 3.3+
- Git installed
- Basic Command Line Interface, Python and Django getting started knowledge
virtualenv. If not, append sudo when installing dependencies if you are using system-provided Python.Optionally:
- Ruby 1.9+ for running
contentful-bootstrapto create your own space with the provided template
Start from a demo application
First we’ll start with a demo project, which is a simple Django getting started application using a basic Blog template, so that you can see it running for yourself.
Run the following commands to get started.
- Clone the example repository:
- Navigate into the repository’s directory:
- Install dependencies:
- Optional Create your space (may result in additional charges if the free spaces available in your plan are exhausted) using Contentful Bootstrap:
After following the steps, the tool will provide you with a Space ID and Access Token. Then run the following commands replacing the values where they correspond:
It should look something like this:

This will allow the application to use your own space, allowing you to edit content and allowing you to see your application changing. You can edit content freely in our web app.
- Run the application:
Everything is now set up. You can view your space by opening http://localhost:8000 in your browser.
It should look something like this:

Deploy the demo to Heroku
To view the demo application live in your own production environment, follow these steps:
- Install the Heroku toolbelt if you don’t already have it.
- Login to Heroku if you’re not already:
- Create a new instance:
- Set Python Buildpack:
- Deploy to Heroku:
-
Optional Add your personalized credentials to your Heroku Instance:
- Open Heroku
- Go to your application
- Go to Settings
- Press Reveal Config Vars
- Add
CTF_SPACE_IDandCTF_DELIVERY_KEYwith their respective values - Go to Resources and restart your application
-
Open the application in your browser:
Next Steps
After this guide, you should be able to start using Contentful with your Django getting started applications, but every project has different needs and we want to provide you with the best solutions we can.
You can read about the Contentful CDA library in more detail on our contentful.py GitHub or our Getting Started with CDA client library tutorial, we also suggest taking a look at our Contentful Django Example Application.
If you want to set up new spaces via the command line we also provide Contentful Bootstrap.