Why "view on site" linked to an unwanted page? Can I disable it?
Asked
Active
Viewed 3,733 times
4 Answers
4
View on site determines the URL to link to by checking the Sites
app and adding the model's get_absolute_url()
method on the end of it.

rennat
- 2,529
- 3
- 26
- 30
3
See the django-docs You can overwrite the admin-templates or see here, how to use it

Community
- 1
- 1

vikingosegundo
- 52,040
- 14
- 137
- 178
1
the easiest and cleanest way is to set admin.site.site_url = None
in your root urls.py
it works since django 1.8, here is the documentation

zabeltech
- 963
- 11
- 27
-
or one can do it in admin.py – comiventor Mar 01 '17 at 08:54
-4
sudo vi /usr/local/lib/python2.6/dist-packages/django/contrib/admin/templates/admin$/change_from.html.
in this file comment out the if condition
{% if has_absolute_url %}
then view on site will never appear

ha22109
- 8,036
- 13
- 44
- 48
-
-
2Don't edit files directly in the packages. Your changes will never (automatically) make it to the production environment, your coworker, etc. – Mark van Lent Jun 26 '14 at 13:37
-
1alternatively, you can copy this template file to your local project template folder and edit it – Hussam Sep 10 '14 at 15:14