Actually support logging in without using the admin interface

This commit is contained in:
Magnus Hagander
2009-09-16 15:07:23 +02:00
parent c24eea14ab
commit f023480689
4 changed files with 37 additions and 2 deletions

View File

@ -1,5 +1,5 @@
from django.conf.urls.defaults import *
from django.contrib.auth.views import logout_then_login
from django.contrib.auth.views import logout_then_login, login
urlpatterns = patterns('',
@ -9,6 +9,9 @@ urlpatterns = patterns('',
(r'^news/(.*)/$', 'news.views.form'),
(r'^events/(.*)/$', 'events.views.form'),
# Log in
(r'^login/$', login, {'template_name':'account/login.html'}),
# Log out
(r'^logout/$', logout_then_login, {'login_url': '/' }),
)

View File

@ -17,3 +17,4 @@ def home(request):
'events': myevents,
}, NavContext(request, 'account'))

View File

@ -70,6 +70,10 @@ TEMPLATE_DIRS = (
'../templates/',
)
LOGIN_URL='/account/login/'
LOGIN_REDIRECT_URL='/account/'
LOGOUT_URL='/account/logout/'
INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',

View File

@ -0,0 +1,27 @@
{%extends "base/page.html"%}
{%block contents%}
<h1>Log in</h1>
<p>
Please log in to your community account.
</p>
<form action="." method="post" id="login-form">
<div class="form-row">
<label for="id_username">Username:</label> <input type="text" name="username" id="id_username" />
</div>
<div class="form-row">
<label for="id_password">Password:</label> <input type="password" name="password" id="id_password" />
<input type="hidden" name="this_is_the_login_form" value="1" />
</div>
<div class="submit-row">
<label>&nbsp;</label><input type="submit" value="Log in" />
</div>
</form>
<script type="text/javascript">
document.getElementById('id_username').focus()
</script>
</div>
{%endblock%}