TL;DR: There’s no any “standard” “Django-ish” way of doing that, but the DRY principle promoted by the framework assumes the single configuration store, so a custom setting seems to be a good way to go.
By default Django can serve any number of domains from a single instance, and the HTTP request (more accurately, its HTTP_HOST header) is the only thing Django uses to determine the current host.
As your cron jobs are obviously out of the HTTP cycle, you should store your domain somewhere in settings…
# settings.py
DEFAULT_DOMAIN = 'https://foobar.com'
# or, depending on your configuration:
DEFAULT_DOMAIN = 'https://{}'.format(ALLOWED_HOSTS[0])
…with a tiny context processor to make it easier to handle templating:
# yourapp/context_processors.py
from django.conf import settings
def default_domain(request):
return {'default_domain': settings.DEFAULT_DOMAIN}
…and then use it in your emails:
# yourapp/templates/email/body.html
<a href="https://stackoverflow.com/questions/34989031/{{ default_domain }}{% url"target' %}">Click here</a>
Alternatively you can make use of the sites framework, but if you’re serving a single domain, the settings-based solution seems much more simpler and cleaner to me.