Peter Harley wrote: > Hi all, > > I was wondering if anyone had any suggestions on how to approach what I > imagine is a fairly common issue. > > Say for example I'm developing a blog app (just to reinvent the wheel.... > again). In my blog posts I want to link to something else on my site. > Normally I would use reverse (or {% url ... %} in a template) to avoid hard > coding urls. If I'm saving my post to the database though, theres no way to > do this. >
Well, there's nothing actually stopping you running a text string fetched from a database rather than a file through the django template system? OTOH, you might not actually want to expose full django templating to blog post authors. http://docs.djangoproject.com/en/dev/ref/templates/api/#rendering-a-context ./manage.py shell from django.contrib.auth.models import User from django.template import Template, Context s = 'Hello <a href="{{ u.get_absolute_url }}">{{u.username}}</a>' t = Template(s) u = User.objects.get(username='blah') c = Context(dict(u=u)) print t.render(c) => Hello <a href="/accounts/user/blah/">blah</a> --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---