django-wordpress-rest
Welcome to django-wordpress-rest!
Summary
Django-wordpress-rest is a Django application that syncs content from a WordPress.com site to a Django site.
This is done using the WordPress.com 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.
Quickstart
Install the module:
pip install django-wordpress-rest
Add "wordpress" to your INSTALLED_APPS setting:
INSTALLED_APPS = (
# ...
"wordpress",
# ...
)
Create the database tables that will persist the sync’d WordPress content:
$ python manage.py 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 manage.py load_wp_api <site_id>
Authentication
If you’d like to synchronize private content, create an OAuth2 access token using the instructions provided by WordPress: https://developer.wordpress.com/docs/oauth2/
Add this token to your Django settings.py file. Use an environment variable to keep things secure:
WP_API_AUTH_TOKEN = os.getenv("WP_API_AUTH_TOKEN")
Load Options
Bring the site content up to date:
# first run gets everything $ python manage.py load_wp_api <site_id> # second run gets content modified since previous run $ python manage.py load_wp_api <site_id>
Do a full sweep of the site content, inserting and updating as needed:
# first run gets everything $ python manage.py load_wp_api <site_id> # second run gets/updates all content again $ python manage.py load_wp_api <site_id> --full
Load everything modified after a given date:
$ python manage.py load_wp_api <site_id> --modified_after=2015-01-01
Just load posts, not pages, attachments, or reference data:
$ python manage.py load_wp_api <site_id> --type=post
Load posts with a specific status (note this requires authentication):
$ python manage.py load_wp_api <site_id> --status=draft
Purge local content before loading – careful!
$ python manage.py load_wp_api <site_id> --purge --full
Webhook
If you’d like to use the webhook to sync a post immediately after it’s updated, include the urls into your project’s urls.py, 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):
INSTALLED_APPS = (
# ...
"after_response",
"wordpress",
# ...
)
The webhook looks for your <site_id> in Django settings. So add this your settings.py, and use an environment variable to keep things secure:
WP_API_SITE_ID = os.getenv("WP_API_SITE_ID")
Finally from your WordPress.com 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" http://mydjangosite.com/wordpress/load_post
Running the Tests
$ pip install detox $ detox
Metadata
Release files for django-wordpress-rest 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-wordpress-rest-0.1.4.whitespacefix.tar.gz | 17.4 kB | Without provenance | Details for django-wordpress-rest-0.1.4.whitespacefix.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_wordpress_rest-0.1.4.whitespacefix-py2.py3-none-any.whl | Details for django_wordpress_rest-0.1.4.whitespacefix-py2.py3-none-any.whl |
Total release size: 39.2 kB
Release files / django-wordpress-rest-0.1.4.whitespacefix.tar.gz
| Download URL | django-wordpress-rest-0.1.4.whitespacefix.tar.gz |
|---|---|
| Size | 17.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e497ebd92c6835949cc249ce6ada4c47af643e18f5354d6cdb0312dba8d1d045
|
|
BLAKE2b-256 checksum How to use checksums |
d5f0558863746345b133c8c8ac82f19b0289b3d5c20521d22ab9fb83dff23fcd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django_wordpress_rest-0.1.4.whitespacefix-py2.py3-none-any.whl
| Download URL | django_wordpress_rest-0.1.4.whitespacefix-py2.py3-none-any.whl |
|---|---|
| Size | 21.8 kB |
|
SHA-256 checksum How to use checksums |
026b85c910f3194c21f467cb3bfc87711aa24cc2ab702aad963fe84dc4eda556
|
|
BLAKE2b-256 checksum How to use checksums |
de87e9158f40d74e2b17db7cdd128dfa52e94086af6649fc01ee07fc96498307
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-wordpress-rest 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.