from django.core.urlresolvers import reverse

def get_flatpage_absolute_url(o):
   return '%s%s' % (reverse('site-index'), o.url)

ABSOLUTE_URL_OVERRIDES = {
        'flatpages.flatpage': get_flatpage_absolute_url
}

Actually I think this would work too:
ABSOLUTE_URL_OVERRIDES = {
        'flatpages.flatpage': lambda o: '%s%s' % (reverse('site-index'), o.url)
}

Erik

On 04.10.2008, at 19:42, John Allen wrote:

>
> There are a few fairly recent threads touching this issue - including
> one of mine - but I'd like to ask a new question.
>
> The FlatPage model requires an explicity defined - ie hard-coded - URL
> and get_absolute_url() is set equal to this hard-coded URL (eg "/
> about/").
>
> For my purposes I needed to add a site-dependent root folder to all
> these URLs, which can be done like this in the settings.py file:
>
> ABSOLUTE_URL_OVERRIDES = {
>    'flatpages.flatpage': lambda o: "/cms%s" % o.url,
> }
>
> so that the URL becomes /cms/about/
>
> This works fine but I am wondering: can the function in
> ABSOLUTE_URL_OVERRIDES make use of reverse(), so as to avoid hard-
> coding the "/cms" into the setting?
>
> I tried to do this with several variants of what looked to me (as a
> beginner) like plausible syntax, but none of them worked, and I could
> not find any examples on the web. Is there a way to do this, or is
> there some inherent limitation on the type of function which can be
> used with ABSOLUTE_URL_OVERRIDES?
> >


--~--~---------~--~----~------------~-------~--~----~
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