At the end, I'll get these variables directly from the Site module.

And to access to them, can be made using templatetags or context
processors -that is better for this case-.

* Templatetags
-------------------
from django import template
from django.contrib.sites.models import Site


register = template.Library()
current_site = Site.objects.get_current()

def site_domain():
    return current_site.domain

@register.simple_tag
def site_url():
    return "http://www.%s"; % (site_domain())

@register.simple_tag
def site_name():
    return current_site.name
-------------------

* Context processors
-------------------
from django.contrib.sites.models import Site


def site(request):
    """Adds site-related context variables to the context.
    """
    current_site = Site.objects.get_current()

    return {
        'SITE_NAME': current_site.name,
        'SITE_DOMAIN': current_site.domain,
        'SITE_URL': "http://www.%s"; % (current_site.domain),
    }
-------------------

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to