Django Sites framework for local development

Recently, in an application I am writing with Django, I needed to get the domain name for an email that was being sent with django-registration.

Django-registration generates a unique code to activate a user account. You know, the typical workflow of register on the website, receive a confirmation email, click an activation link, done. Since django-registration relies on you to create the URL with the unique code on it, and it only gives you a site variable, which is an instance of django.contrib.sites.models.Site, you need to use the sites framework and have at least one site configured for this to work.

But since the current site is statically defined by default in settings.py, how do you send test emails with activation links that point to your local machine instead of the live application domain?

The rather simple approach I took was to configure two sites in Django admin, the first one being the development site and the second the live site, and then make the SITE_ID setting depend on the DEBUG flag, like this: DEBUG = bool(os.environ.get(‘DJANGO_DEBUG’, True)) SITE_ID = 1 if DEBUG else 2

Would you do something differently?