收录日期:2019/10/22 14:30:46 时间:2009-11-11 02:21:53 标签:django,redirect,django-admin

I am using the latest checkout of the django trunk - when I am in the admin on the "change" page for an object/item, there is a nice little link that says "view on site".

The link points to a url such as:

http://example.com:8888/admin/r/22/15/

However, when I click on that link (or enter that link into my browser) I get redirected to:

http://example.com:8888//example.com:8888/video/15

Which isn't a valid url - but it's really, really close ... the same is happening when I try to get_absolute_url for a comment. I get the short little redirect but it doesn't take me to the right page.

Any ideas why this is happening?

Additional Info (edit):

I thought maybe it had to do with the port number at the end - but what is strange is the my object's get_absolute_url works without a hitch.

I think the problem is coming from django.contrib.contenttypes.views.shortcut which is doing some funny appending business to handle cross-site things ... which I don't quite understand.

get_absolute_url (for objects)

@models.permalink
def get_absolute_url(self):
    return ('video_detail', [str(self.id)])

I figured it out: my site's 'domain name' was listed as:

http://example.com

But the 'http' is what is throwing it off. When I removed it and just listed it as:

example.com

It works. I just have to update my email templates to include the 'http', I think ... unless django comes with a built in for adding that in its sites package. Off to investigate ...