Florian Lindner wrote: > Hello, > a common problem I have is that I have references in my main template like > CSS > or an background image: > > <link rel="stylesheet" type="text/css" href="styles.css" /> > > This template is used within different paths. Therefore I need to have the > styles.css availabe in every path the template could be used.
I'm using a custom tag. I have in all my templates at the top an {% extends base.html %} which contains the DOCTYPE, html header etc. The base.html template is like this: {% load template_extensions %} <html> <head> <link rel="stylesheet" type="text/css" href="{% url_root %}/static/styles.css" /> etc... In my_app/templatetages/ I have template_extensions.py # My custom tag and filter definitions. from django.template import Library import re register = Library() def url_root(): ''' Returns the string for the root URL as set in the settings.py file. ''' try: from django.conf import settings except: return '- Cannot import settings file -' return settings.URL_ROOT and in settings.py I have: URL_ROOT = '/path_to/my_app' # Don't include any trailing / -- Michael Lake Computational Research Support Unit Science Faculty, UTS Ph: 9514 2238 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---