1

Why "view on site" linked to an unwanted page? Can I disable it?

nathan gonzalez
  • 11,817
  • 4
  • 41
  • 57
ha22109
  • 8,036
  • 13
  • 44
  • 48

4 Answers4

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
-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 %}

  • {% trans "View on site" %}
  • {% endif%}

    then view on site will never appear

    ha22109
    • 8,036
    • 13
    • 44
    • 48
    • Editing core files should be LAST resort, if it should be used at all! – frnhr Feb 25 '14 at 18:49
    • 2
      Don'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
    • 1
      alternatively, you can copy this template file to your local project template folder and edit it – Hussam Sep 10 '14 at 15:14