Added Template context processors and Session Expire time for auth module.
--- a/conference/views.py Fri Oct 02 14:01:09 2009 +0530
+++ b/conference/views.py Fri Oct 02 14:01:48 2009 +0530
@@ -32,8 +32,8 @@
") %{'username': username,'url': url}
return msg
-def home_page(request, template_name='index.html'):
- return render_to_response(template_name)
+def home(request, template_name='home.html'):
+ return render_to_response(template_name, RequestContext(request, {}))
def logout(request):
print request.user.username
--- a/settings.py Fri Oct 02 14:01:09 2009 +0530
+++ b/settings.py Fri Oct 02 14:01:48 2009 +0530
@@ -12,6 +12,10 @@
MANAGERS = ADMINS
+SESSION_EXPIRE_AT_BROWSER_CLOSE = True
+
+DEFAULT_FROM_EMAIL = 'admin@scipy.in'
+
DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'conference' # Or path to database file if using sqlite3.
DATABASE_USER = 'root' # Not used with sqlite3.
@@ -57,6 +61,14 @@
AUTH_PROFILE_MODULE = 'conference.participant'
+# List of context processors.
+TEMPLATE_CONTEXT_PROCESSORS = (
+ 'django.core.context_processors.auth',
+ 'django.core.context_processors.debug',
+ 'django.core.context_processors.i18n',
+ 'django.core.context_processors.media'
+)
+
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
--- a/template/index.html Fri Oct 02 14:01:09 2009 +0530
+++ b/template/index.html Fri Oct 02 14:01:48 2009 +0530
@@ -47,12 +47,12 @@
<ul>
<li>
<ul>
- {% if request.user.is_anonymous %}
- <li><a href="login">login</a> </li>
- <li><a href="#">register</a> </li>
- {% else %}
- <li>{{ request.user.username }}</li>
- <li><a href="logout" >{% trans "logout" %}</a></li>
+ {% if user.is_authenticated %}
+ <li>{{ user.username }}</li>
+ <li><a href="logout" >{% trans "Logout" %}</a></li>
+ {% else %}
+ <li><a href="login">Login</a> </li>
+ <li><a href="#">Register</a> </li>
{% endif %}
</ul>
<li id="categories">
--- a/urls.py Fri Oct 02 14:01:09 2009 +0530
+++ b/urls.py Fri Oct 02 14:01:48 2009 +0530
@@ -18,7 +18,7 @@
# Uncomment the next line to enable the admin:
# (r'^admin/', include(admin.site.urls)),
- url (r'^$', direct_to_template, {"template": "homepage.html"}, name="home"),
+ url (r'^$', 'conference.views.home'),
(r'^accounts/', include('registration.urls')),
(r'^register/','conference.views.register'),
(r'^logout/','conference.views.logout'),