Skip to main content
Help us improve Python packaging – donate today!

Sync a WordPress site to Django via the REST API

Project Description Documentation Status

Welcome to django-wordpress-rest!


Django-wordpress-rest is a Django application that syncs content from a site to a Django site.

This is done using the REST API. A separate copy of the content data is stored on the Django side, which allows for loose coupling and extensability.

Full documentation is available on Read The Docs.


Install the module:

pip install django-wordpress-rest

Add "wordpress" to your INSTALLED_APPS setting:

    # ...
    # ...

Create the database tables that will persist the sync’d WordPress content:

$ python migrate

Sync WordPress content using the management command. The <site_id> can be found using the /me/sites WordPress API call. This is useful for periodically updating the content with cron.

$ python load_wp_api <site_id>


If you’d like to synchronize private content, create an OAuth2 access token using the instructions provided by WordPress:

Add this token to your Django file. Use an environment variable to keep things secure:


Load Options

Bring the site content up to date:

# first run gets everything
$ python load_wp_api <site_id>

# second run gets content modified since previous run
$ python load_wp_api <site_id>

Do a full sweep of the site content, inserting and updating as needed:

# first run gets everything
$ python load_wp_api <site_id>

# second run gets/updates all content again
$ python load_wp_api <site_id> --full

Load everything modified after a given date:

$ python load_wp_api <site_id> --modified_after=2015-01-01

Just load posts, not pages, attachments, or reference data:

$ python load_wp_api <site_id> --type=post

Load posts with a specific status (note this requires authentication):

$ python load_wp_api <site_id> --status=draft

Purge local content before loading – careful!

$ python load_wp_api <site_id> --purge --full


If you’d like to use the webhook to sync a post immediately after it’s updated, include the urls into your project’s, like so:

from django.conf.urls import include

urlpatterns = [
    url(r'^wordpress/', include('wordpress.urls'))

Add "after_response" to your INSTALLED_APPS setting (this allows asynchronous processing):

    # ...
    # ...

The webhook looks for your <site_id> in Django settings. So add this your, and use an environment variable to keep things secure:

WP_API_SITE_ID = os.getenv("WP_API_SITE_ID")

Finally from your site, submit a POST request with an ID data element in the body to trigger a sync of a single post. Note this should be the WordPress Post ID, not the Django one!

$ curl -X POST --data "ID=123456"

Running the Tests

$ pip install detox
$ detox

Release history Release notifications

This version
History Node


History Node


History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
django_wordpress_rest-0.1.4.whitespacefix-py2.py3-none-any.whl (21.8 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Oct 8, 2015
django-wordpress-rest-0.1.4.whitespacefix.tar.gz (17.4 kB) Copy SHA256 hash SHA256 Source None Oct 8, 2015

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page