“View on site” button is linked to an unwanted page

回眸只為那壹抹淺笑 提交于 2019-12-11 09:52:54

问题


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


回答1:


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.




回答2:


See the django-docs You can overwrite the admin-templates or see here, how to use it




回答3:


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




回答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



    来源:https://stackoverflow.com/questions/964868/view-on-site-button-is-linked-to-an-unwanted-page

    易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
    该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!