Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override default get_absolute_url on User objects?

I'm trying to make a generic table for listing django_tables objects. I've got everything working, except that the get_absolute_urls() on my User objects returns:

/users/<username>/

While I could create this URL, it doesn't match with the rest of the site layout, so I'm looking for another way to do this. Is there a way to override this value without breaking the built in authentication and other functionality?

like image 613
Jack M. Avatar asked Feb 24 '10 19:02

Jack M.


1 Answers

You can do this in your settings.py file using the setting ABSOLUTE_URL_OVERRIDES

ABSOLUTE_URL_OVERRIDES = {     'auth.user': lambda u: "/users/%s/" % u.username, } 

Here's a link to the official docs: https://docs.djangoproject.com/en/stable/ref/settings/

like image 110
Mark Lavin Avatar answered Sep 19 '22 14:09

Mark Lavin