Skip to main content

Django integration with WordPress authentication and roles / capabilities system.

Project description


Allows for access in Django to a WordPress installation for checking for things like login status and roles / capabilities.


Python Dependencies :

Wordpress Dependencies :


Add your WordPress’s auth keys and salts (found in wp-config.php) to your

WORDPRESS_LOGGED_IN_KEY = "rs&^D%jPdu=vk|VVDsdfsdgsdgsdg9sd87f98s7h[Xm$3gT/@1xdasd"
WORDPRESS_LOGGED_IN_SALT = "3]x^n{d8=su23902iu09jdc09asjd09asjd09jasdV-Lv-OydAQ%?~"

Add your WordPress database to DATABASES in

    'default': {
        ... # default django DB
    'wordpress': {  # must be named 'wordpress'
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'wordpress',
        'USER': '...',
        'PASSWORD': '...',
        'HOST': '...',
        'PORT': 3306,

Add the middleware to MIDDLEWARE_CLASSES in Make sure it’s placed somewhere after the session middleware.

    # ...

Finally, add wordpress_auth to INSTALLED_APPS.

    # ...


To restrict a view to a certain role, simply wrap the view in the wordpress_requires_role decorator.

from wordpress_auth.decorators import wordpress_requires_role

def my_view():

You can restrict a view to a capability as well.

from wordpress_auth.decorators import wordpress_requires_capability

def my_view():

Finally, the middleware provides access to the WordPress user via request.wordpress_user.

See for full reference. Some of the redundant naming conventions in the WordPress database have been made simpler as well.

Project details

Download files

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

Source Distribution

django-wordpress-auth-0.1.1.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distribution

django_wordpress_auth-0.1.1-py2.py3-none-any.whl (7.8 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page