# django-wordpress: Integrate WordPress Content into Django

This repository profile is provided by osrepos.com, an open source repository discovery platform.

Source: osrepos.com
Repository profile: https://osrepos.com/repo/istrategylabs-django-wordpress
Generated for open source discovery and AI-assisted research.

django-wordpress provides a robust solution for integrating WordPress content directly into Django applications. It offers read-only models and views, ensuring the safety of your WordPress database while allowing seamless access to posts, pages, and other data. This package is ideal for developers looking to leverage existing WordPress content within a Django framework.

GitHub: https://github.com/istrategylabs/django-wordpress
OSRepos URL: https://osrepos.com/repo/istrategylabs-django-wordpress

## Summary

django-wordpress provides a robust solution for integrating WordPress content directly into Django applications. It offers read-only models and views, ensuring the safety of your WordPress database while allowing seamless access to posts, pages, and other data. This package is ideal for developers looking to leverage existing WordPress content within a Django framework.

## Topics

- django
- wordpress
- python
- django-models
- web-development
- blogging
- cms-integration

## Repository Information

Last analyzed by OSRepos: Wed Jul 29 2026 16:20:25 GMT+0100 (Western European Summer Time)
Detail views: 2
GitHub clicks: 1

## Safety Notice

OSRepos shares public repositories for knowledge and discovery only. Review source code, dependencies, licenses, and security implications before running or installing anything.

## Content

## Introduction

`django-wordpress` is a powerful Django package designed to integrate WordPress content directly into your Django applications. Developed by ISL and the Sunlight Foundation, it provides models and views for reading data from a WordPress database, compatible with WordPress version 3.5 and above.

A key feature is its **read-only design** by default, protecting your WordPress content from accidental modifications. While writing can be enabled, it's strongly advised against due to the lack of WordPress-specific logic. The package also supports custom WordPress table prefixes and multiple database configurations, offering flexibility for various setups. Default templates are included for development, encouraging users to override them for production.

## Installation

To get started with `django-wordpress`, follow these simple steps:

First, install the package using pip:

bash
pip install the-real-django-wordpress


Next, add `'wordpress'` to your `INSTALLED_APPS` in `settings.py`:

python
INSTALLED_APPS = [
    # ...
    'wordpress',
    # ...
]


Finally, include the WordPress URLs in your project's `urls.py`:

python
from django.urls import path, include

urlpatterns = [
    # ...
    path('path/to/blog/', include('wordpress.urls')),
    # ...
]


If you are using multiple databases, remember to configure your database routers:

python
DATABASE_ROUTERS = ['wordpress.router.WordpressRouter']


## Examples

Working with WordPress models is straightforward. Here are a few common examples:

Retrieve the ten most recent published posts:

python
from wordpress.models import Posts
Posts.objects.published()[:10]


Find posts tagged "wordpress":

python
from wordpress.models import Posts
Posts.objects.term("wordpress")


Access attachments for a specific post:

python
for attachment in post.attachments():
    # Process attachment
    pass


Get all tags associated with a post:

python
post.tags()


## Why Use django-wordpress?

`django-wordpress` offers several compelling reasons for integration:

*   **Seamless Integration**: Easily bring your existing WordPress blog content into a Django application without complex migrations or data duplication.
*   **Data Safety**: Its default read-only mode provides a secure way to access WordPress data, minimizing the risk of unintended changes to your live WordPress site.
*   **Flexibility**: Supports custom table prefixes and multiple database configurations, adapting to diverse WordPress setups.
*   **Export Capabilities**: Includes management commands like `wpexport` to dump published posts in WXR format and `wpexportauthors` to export authors as CSV.
*   **Developer Friendly**: Provides a clear API for querying WordPress data using Django's ORM.

## Links

*   **GitHub Repository**: <a href="https://github.com/jcarbaugh/django-wordpress" target="_blank">jcarbaugh/django-wordpress</a>