Skip to content
Example app for Contentful in Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
i18n Add en-US as default static fallback locale (#27) Feb 14, 2018
lib Fix missing draft pill (#29) Feb 22, 2018
public E2E Tests added and fixed some found issues (#32) Mar 21, 2018
routes Update to use environments (#34) Apr 19, 2018
services Update to use environments (#34) Apr 19, 2018
tests E2E Tests added and fixed some found issues (#32) Mar 21, 2018
views Add mobile (#36) Sep 4, 2018
.gitignore Find Cypress Specs (#33) Mar 21, 2018
Makefile Add remaining integration tests Dec 6, 2017
Procfile Add Heroku dependencies Dec 6, 2017 Fix/change editorial features param (#25) Feb 5, 2018 Initial commit Nov 30, 2017
app.json Add new settings page and README Dec 8, 2017 Update error page to latest spec (#28) Feb 15, 2018
requirements.txt Update to use environments (#34) Apr 19, 2018 Add ms stripping and fix style Dec 14, 2017

The Python example app


The Python example app teaches the very basics of how to work with Contentful:

  • consume content from the Contentful Delivery and Preview APIs
  • model content
  • edit content through the Contentful web app

The app demonstrates how decoupling content from its presentation enables greater flexibility and facilitates shipping higher quality software more quickly.

Screenshot of the example app

You can see a hosted version of The Python example app on Heroku.

What is Contentful?

Contentful provides a content infrastructure for digital teams to power content in websites, apps, and devices. Unlike a CMS, Contentful was built to integrate with the modern software stack. It offers a central hub for structured content, powerful management and delivery APIs, and a customizable web app that enable developers and content creators to ship digital products faster.


  • Python 2.7+ or 3.3+ (if running tests locally 3.3+ is required)
  • Git
  • Contentful CLI (only for write access)

Without any changes, this app is connected to a Contentful space with read-only access. To experience the full end-to-end Contentful experience, you need to connect the app to a Contentful space with read and write access. This enables you to see how content editing in the Contentful web app works and how content changes propagate to this app.

Common setup

Clone the repo and install the dependencies.

git clone
pip install -r requirements.txt

Steps for read-only access

To start the server, run the following

make run

Open http://localhost:3000 and take a look around.

Steps for read and write access (recommended)

Step 1: Install the Contentful CLI

Step 2: Login to Contentful through the CLI. It will help you to create a free account if you don't have one already.

contentful login

Step 3: Create a new space

contentful space create --name 'My space for the example app'

Step 4: Seed the new space with the content model. Replace the SPACE_ID with the id returned from the create command executed in step 3

contentful space seed -s '<SPACE_ID>' -t the-example-app

Step 5: Head to the Contentful web app's API section and grab SPACE_ID, DELIVERY_ACCESS_TOKEN, PREVIEW_ACCESS_TOKEN.

Step 6: Open .env and inject your credentials so it looks like this


Step 7: To start the server, run the following

make run

Final Step:

Open http://localhost:3000?editorial_features=enabled and take a look around. This URL flag adds an “Edit” button in the app on every editable piece of content which will take you back to Contentful web app where you can make changes. It also adds “Draft” and “Pending Changes” status indicators to all content if relevant.

Deploy to Heroku

You can also deploy this app to Heroku:


You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.