GitXplorerGitXplorer
k

django-allowedsites

public
22 stars
9 forks
2 issues

Commits

List of commits on branch master.
Unverified
8f00cacd515311585b113a9c034e8a9d1bd4e859

fixed PyPI Development status in setup.py

nnanuxbe committed 10 years ago
Unverified
7687fa45af759e1942c16dd0fa43d70ccd3437fe

Merge pull request #2 from nanuxbe/master

kkezabelle committed 10 years ago
Unverified
b2be3356a127706e33a9da16e47b46723d1bbffb

updated setup.py languages and status

nnanuxbe committed 10 years ago
Unverified
68d7d5bf6c8a2ef8d8415b6f7f7ae2854baa9be5

updated tests and doc for Django 1.8

nnanuxbe committed 10 years ago
Unverified
bd48a6d75c4221aa1cf842756bc8f080924597af

add badge.

kkezabelle committed 10 years ago
Unverified
3afc5037eb3789c0031fadd0522300e7b82ed288

test the basic AllowedSites instances.

kkezabelle committed 10 years ago

README

The README file for this repository.

=================== django-allowedsites

Django 1.6+ library for setting your ALLOWED_HOSTS based on the domains in django.contrib.sites

.. image:: https://travis-ci.org/kezabelle/django-allowedsites.svg?branch=master :target: https://travis-ci.org/kezabelle/django-allowedsites

Usage is something like the following, in your settings.py or equivalent::

from allowedsites import AllowedSites
ALLOWED_HOSTS = AllowedSites(defaults=('mytestsite.com',))

Or, if you want to use your cache backend::

from allowedsites import CachedAllowedSites
ALLOWED_HOSTS = CachedAllowedSites()

A single key, allowedsites will be inserted containing an unsorted collection of all the domains that are in the django.contrib.sites. For the sake of allowing multiple processes to keep up to date with the Site values without hitting the database, using a shared cache (ie: not LocMemCache) is encouraged.

The CachedAllowedSites also provides an update_cache class method which may be used as a signal listener::

from django.db.models.signals import post_save
from django.contrib.sites.models import Site
post_save.connect(CachedAllowedSites.update_cache, sender=Site,
                  dispatch_uid='update_allowedsites')

You can modify the the defaults::

from allowedsites import AllowedSites
ALLOWED_HOSTS = AllowedSites(defaults=('mytestsite.com',))
ALLOWED_HOSTS += AllowedSites(defaults=('anothersite.net',))
ALLOWED_HOSTS -= AllowedSites(defaults=('mytestsite.com',))
# ultimately, only anothersite.net is in the defaults

Other uses?

It may work with django-csp_ (Content Security Policy headers), django-dcors_ (Cross-Origin Resource Sharing headers) and others. I don't know.

.. _django-csp: https://github.com/mozilla/django-csp .. _django-dcors: https://github.com/prasanthn/django-dcors