How can you get the absolute uri (with domain and scheme (http/https)) from a batch/cron job?
The method build_absolute_uri() needs an HttpRequest, which I don't have in a cron job.
How can you get the absolute uri (with domain and scheme (http/https)) from a batch/cron job?
The method build_absolute_uri() needs an HttpRequest, which I don't have in a cron job.
Two examples:
from django.contrib.sites.models import Site
url = 'http://' + Site.objects.get_current().domain + my_obj.get_absolute_url()
or
from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse
url = 'http://' + Site.objects.get_current().domain + reverse('my_view')