Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Admin's "view on site" points to example.com instead of my domain

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?

like image 593
Patrick McElhaney Avatar asked Dec 05 '08 19:12

Patrick McElhaney


People also ask

What is Admin Modeladmin in Django?

One of the most powerful parts of Django is the automatic admin interface. It reads metadata from your models to provide a quick, model-centric interface where trusted users can manage content on your site. The admin's recommended use is limited to an organization's internal management tool.

Is Django's admin interface customizable if yes then how?

In this article, we will discuss how to enhance Django-admin Interface. Let us create an app called state which has one model with the same name(state). When we register app to admin.py it shows like. Now lets' customize django admin according to available options.


2 Answers

You have to change default site domain value.

like image 85
Alex Koshelev Avatar answered Sep 27 '22 19:09

Alex Koshelev


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 :)

like image 28
Zaur Nasibov Avatar answered Sep 27 '22 18:09

Zaur Nasibov