如何绕过django admin index并转到特定的应用页面? [英] How to bypass django admin index and go to a specific application page?

查看:414
本文介绍了如何绕过django admin index并转到特定的应用页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个只有一个应用程序的Django项目。



我不需要网站管理员(与我的应用程序管理员一样),所以我想绕过站点管理员,直接进入我的应用程序管理员,即登录后直接进入 mysite / admin / myapp / 并删除 Home 在面包屑中。



我该怎么做?

解决方案

您可以做的是覆盖管理员索引页面以重定向到特定于应用的管理页面。



如@FallenAngel所述,您需要更新网址.py以查看管理员索引页面。该视图可以重定向到内部应用程序管理页面。

  from django.http import HttpResponseRedirect 
from django.core import urlresolvers
def home(request):
return HttpResponseRedirect(urlresolvers.reverse('admin:app_list',args =(myapp,)))
pre>

I've got a Django project with only one app.

I don't need the site admin (same as my app admin), so I would like to bypass the site admin and go directly to my app admin, i.e. go directly to mysite/admin/myapp/ after loging in and removing Home in the breadcrumb.

How can I do that?

解决方案

What you can do is override the admin index page to redirect to app specific admin page.

As stated by @FallenAngel, you need to update the urls.py to have your view for admin index page. That view can redirect to inner app admin page.

from django.http import HttpResponseRedirect
from django.core import urlresolvers
def home(request):
    return HttpResponseRedirect(urlresolvers.reverse('admin:app_list', args=("myapp",)))

这篇关于如何绕过django admin index并转到特定的应用页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆