Getting started


pip install airavata


Add airavata and django.contrib.sites to your installed apps



Make sure SITE_ID in not set in


Airavata provides two wrapper classes to fetch ALLOWED_HOSTS from the database instead of hard-coding them. These two classes are extended from kezabelle’s django-allowedsites. Namely they are airavata.utils.AllowedSites and airavata.utils.CachedAllowedSites. Use either of those in your

from airavata.utils import AllowedSites
ALLOWED_HOSTS = AllowedSites()

Cache invalidation

If you are planning on using CachedAllowedSites, don’t forget to register cache invalidation signals in your AppConfig.

from django.apps import AppConfig
from airavata.utils import register_signals

class MyAppConfig(AppConfig):
  name = 'my_app'
  verbose_name = "My app"

  def ready(self):
        from django.contrib.sites.models import Site
        from airavata.models import SiteAlias
        for model in [Site, SiteAlias]:

default_app_config = 'my_app.apps.MyAppConfig'


Cache is supposed to be shared among Django instances in order for this process to work. Read more about cache

Set the domain for your primary site

Once django.contrib.sites is added to your Django won’t let you access your website unless one of the following is true:

  • SITE_ID is also set in your (which we don’t want to do since this library is for hosting multiple dynamic sites)
  • DEBUG is set to True which is ok for dev but not for live servers
  • Django finds a Site (or a SiteAlias with Airavata) corresponding to the host you are requesting

In order to set the correct domain on the first site in your database, Airavata provides a management command. Simply run

python setprimarydomain