至此,excel可以上传,查看,布局,基本的web功能都已实现,但我们需要对上传或者查看的用户给与权限控制,让有权限的用户可以进行相关操作

在页面添加用户testuser/123456
编辑用户,选中
 
修改settting.py
在末尾添加DOWNLOAD_USER = ‘testuser’
修改/exceltest/views.py
添加
from django.conf import settings
from django.contrib.admin.views.decorators import staff_member_required
@staff_member_required
def output(request):
    if request.user.username != settings.DOWNLOAD_USER:
      return render_to_response(‘exceltest/error.html’,{‘message’:'你需要使用 %s 登录才能导出数据!’ %setting.DOWNLOAD_USER})
 
此时,点击下载链接,如果为登陆,会自动跳转到admin登陆页面,如果登陆,但登陆用户不为testuser,提示登陆用户错误










































































































































































































Brubaker said setting and monitoring weekly goals for each student makes the difference between gossip and real student support Touching the hearts of www.collegepapers.co.uk our students isn’t easy

标签: ,
本文连接地址: http://www.fresker.com/archives/530 (转载注明出处)

回复

目前暂无评论

Sorry, 评论已关闭.