添加install

pull/2/head
guanghongwei 2014-09-27 20:16:10 +08:00
parent 7d32a9a9e9
commit 5ccffe6c1d
2 changed files with 17 additions and 0 deletions

View File

@ -10,6 +10,7 @@ urlpatterns = patterns('',
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
(r'^install/', views.install),
(r'^$', views.index),
(r'^login/$', views.login),
(r'^logout/$', views.logout),

View File

@ -207,6 +207,22 @@ def is_super_user(request):
return False
def install(request):
user = User.objects.filter(username='admin')
if user:
return HttpResponseRedirect('/login/')
else:
u = User(
username='admin',
password=md5_crypt('admin'),
key_pass=md5_crypt('admin'),
name='admin',
is_admin=False,
is_superuser=True,
ldap_password=md5_crypt('admin'))
u.save()
def login(request):
"""登录界面"""
if request.session.get('username'):