and related to this:

if your django site needs to be running at someplace besides '/' (say
for a beta installation or a subsite)
then permalinks and reverse will work correctly,
but user.get_absolute_url() will not
it will return

/user/username/
rather than
/subsite/user/username/

so,

def _user_get_absolute_url(user):
    from django.core.urlresolvers import reverse
    return reverse('account',kwargs={'username':user.username})

ABSOLUTE_URL_OVERRIDES = {
    'auth.user' : _user_get_absolute_url
}



On Sep 16, 11:34 pm, Sven Richter <[EMAIL PROTECTED]> wrote:
> 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 inget_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...
>
> 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 theget_absolute_urlfunction.
> This works for any installed model in the project.
>
> Docs can be found 
> here:http://docs.djangoproject.com/en/dev/ref/settings/#absolute-url-overr...
>
> 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