On Tue, 2008-09-16 at 15:11 -0300, Eduardo O. Padoan wrote:
> On Tue, Sep 16, 2008 at 2:59 PM, Sven Richter <[EMAIL PROTECTED]> wrote:
> >
> > Hi,
> >
> > i am wondering if the "users" path in get_absolute_url
> > from the User class is hardcoded?
> > I mean this line:
> > return "/users/%s/" % urllib.quote(smart_str(self.username))
> >
> > I have the problem that all my profiles want to reside
> > under /profile/username and not /users/username.
> >
> > Can i subclass this Model and overwrite the function
> > somehow?
> > Or is there another way to get my profiles path
> > without a dirty hack?
> >
> 
> Jannis Leidel have written about it:
> http://jannisleidel.com/2008/08/easy-overrides-absolute-urls-reusable-apps/

Thank you, this pointed me into the right direction.
Just in case somebody is interested in the solution.

In the settings file of the project you have to define the option:
ABSOLUTE_URL_OVERRIDES = {
        'auth.user' : lambda o:'/profile/%s/' % o.username,
}

to overwrite the get_absolute_url function.
This works for any installed model in the project.

Docs can be found here:
http://docs.djangoproject.com/en/dev/ref/settings/#absolute-url-overrides


Greetings
Sven


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