python - How to change the view_site on the Django admin homepage to the URL you want? (Try not to modify the django source code)
我想大声告诉你
我想大声告诉你 2017-06-22 11:51:22
0
2
672


For example, change it to 'www.baidu.com'

我想大声告诉你
我想大声告诉你

reply all(2)
小葫芦

I took a look at the django (1.9.8) source code, and this link is indeed the hard-coded site_url = '/' in the source code (/path/to/python/site-packages/django/contrib/admin/sites.py). Then reference href="{{ site_url }}" in html (/path/to/python/site-packages/django/contrib/admin/templates/admin/base.html) without setting a constant in settings.py What.
If you really don’t want to modify the source code, try adding a custom context_processors at the end of ./settings.py TEMPLATES, and also define a site_url = '/xxx/' in it to see if it can be achieved (I haven’t tested it yet) Pass).
Process:
1. Create a new self_context_processors.py, content:

def set_url(request):

    return {'site_url': '/xxx/'}

2. Add at the bottom of settings TEMPLATE context_processor:
'self_context_processors.set_url',

Peter_Zhu

The crudest way is to copy site-packages/django/contrib/admin/templates/admin/base.html to your project directory/templates/admin/base.html, and then modify href="the url you want"

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!