views:

1415

answers:

4

I added a get_absolute_url function to one of my models.

def get_absolute_url(self):
    return '/foo/bar'

The admin site picks it up and adds a "view on site" link to the detail page for that object (when I put a real URL there instead of "/foo/bar").

The problem is instead of going to http://localhost:8000/foo/bar, it goes to http://example.com/foo/bar.

What am I doing wrong?

+9  A: 

You have to change default site domain value.

Alex Koshelev
Thanks. It took me a while to figure out how to do that. It's an entry in the django_site table. I found and changed it by clicking on "Sites" in the admin.
Patrick McElhaney
+1  A: 

You can change this in /admin/sites if you have admin enabled.

Tony Edgecombe
A: 

The funniest thing is that "example.com" appears in an obvious place. Yet, I was looking for in in an hour or so.

Just use your admin interface -> Sites -> ... there it is :)

BasicWolf
A: 

weirdly, if you set this programmatically it doesn't work... until you press the save button in the admin interface...?

Steve Pike