请问该怎么用django自带的用户登录怎么实现?

用django自带的用户登录怎么实现


www说
浏览 1281回答 3
3回答

九州编程

settings.pyMIDDLEWARE_CLASSES = ('django.middleware.common.CommonMiddleware','django.contrib.sessions.middleware.SessionMiddleware','django.middleware.csrf.CsrfViewMiddleware','django.contrib.auth.middleware.AuthenticationMiddleware','django.contrib.messages.middleware.MessageMiddleware',)INSTALLED_APPS = ('django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.sites','django.contrib.messages','django.contrib.admin','django.contrib.staticfiles',)urls.pyfrom django.conf.urls.defaults import *from django.contrib import adminfrom django.conf import settingsadmin.autodiscover()urlpatterns = patterns('',url(r'^admin/', include(admin.site.urls)),)if settings.DEBUG:urlpatterns = patterns('',url(r'^media/(?P<path>.*)$', 'django.views.static.serve',{'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),url(r'', include('django.contrib.staticfiles.urls')),) + urlpatterns

慕勒3428872

两种方式:使用命令usermod禁止帐号myuser登录usermod -L myuser允许账号登录usermod -U myuser123456修改shell类型chsh myuser -s /sbin/nologin

牛魔王的故事

在服务器上进行如下命令操作进行规则设置即可:#iptables -A INPUT -s ip段/网络位数 -j DROP例如:禁止172.16.1.0/24网段访问服务器,直接在服务器上用命令就可以实现#iptables -A INPUT -s 172.16.1.0/24 -j DROP (添加规则,所有来自这个网段的数据都丢弃)#/etc/rc.d/init.d/iptables save (保存规则)#service iptables restart (重启iptables服务以便升效)
打开App,查看更多内容
随时随地看视频慕课网APP