In your template, you refer to 'user'. This context variable isn't magically generated from pixie dust, it must be added to the context by something.
The typical way is to ensure that it is added is to: Ensure "django.core.context_processors.auth" is in TEMPLATE_CONTEXT_PROCESSORS. Ensure that your template is rendered with a RequestContext. In other words, this is bad: return render_to_response('rsf.html', {'errors': errors}) and this is good: from django.template import RequestContext return render_to_response('rsf.html', RequestContext(request,{'errors': errors})) Your 'rsf' view is not rendered with a RequestContext, which is the probable cause. Cheers Tom On Wed, Nov 10, 2010 at 2:39 PM, octopusgrabbus <old_road_f...@verizon.net> wrote: > urls.py > > from django.conf.urls.defaults import * > from django.contrib.auth.views import login > > from amr.views import current_datetime > from amr.views import display_meta > > from amr.views import collect_reads > > from amr.read_snap.views import rsf > from amr.read_snap.views import after_rs > > from login.views import * > > # Uncomment the next two lines to enable the admin: > from django.contrib import admin > admin.autodiscover() > > urlpatterns = patterns('', > (r'^$', main_page), > (r'^login/$', 'django.contrib.auth.views.login'), > (r'^time/$', current_datetime), > (r'^display_meta/$', display_meta), > (r'^logout/$', logout_page), > (r'^read_snap/$', rsf), > (r'^after_rs/$', after_rs), > > # Uncomment the admin/doc line below to enable admin > documentation: > (r'^admin/doc/', include('django.contrib.admindocs.urls')), > > # Uncomment the next line to enable the admin: > (r'^admin/', include(admin.site.urls)), > ) > > Once a link clicked on the main web page, logic starts here: > base.html > <html> > <!-- Test Comment --> > <head> > <title>{% block title %}Town of Arlington Water Department AMR > System{% endblock %} </title> > </head> > > <body> > <h1>{% block head %}Town of Arlington Water Department AMR > System{% endblock %}</h1> > {% block content %}{% endblock %} > <br> > <!-- > {% if user.is_authenticated %} > <br></br><br></br> > <p>User {{ user.username }} has successfully logged in.</ > p> > <a href="/logout">Log out from AMR System</a> > {% else %} > <a href="/login/">Log into AMR System</a> > {% endif %} > <br> > --> > </body> > </html> > > rsf.html > ----------- > {% extends "base.html" %} > > {% block content %} > <h2>Take Snapshot of Billing Reads</h2> > > {% if errors %} > {% for error in errors %} > {{ error }} > {% endfor %} > <br></br> > {% endif %} > > <form action="." method="post"> {% csrf_token %} > <input type="text" name="cycle" size="1"> > <input type="submit" value="Snap Read"> > </form> > <br></br><br></br><br></br> > <a href="/">AMR Application Main Page</a> > {% endblock content %} > > > Here's the views.py from read_snap > > from django.template import RequestContext > from django.shortcuts import render_to_response > from django.http import HttpResponse, Http404, HttpResponseRedirect > from django.contrib.auth import logout > from django.contrib.auth.models import User > > from subprocess import call, Popen > from datetime import datetime, timedelta > from mx.DateTime.ISO import ParseDateTimeUTC > from ftplib import FTP > > import sys > > from funcs import * > > def runReadSnap(cycle): > rclist = [0, None] > > cmd_line = '/usr/local/bin/python /home/amr/bin/addReadSnap.py -s > ' + str(cycle) > > rc = exec_external_cmd(cmd_line) > > rclist[0] = rc > > if 0 == rc: > message = '<p>Your read snap was successful.</p>' + \ > '<p>The read snap file -- metergun_in.unl -- was ' + \ > 'shipped both to Josephine and ICS (production).</p>' > else: > message = 'Oopsie! The read snap failed with return code = ' + > str(rc) > > rclist[1] = message > return (rclist) > > > def rsf(request): > sys.stderr.write('Entering rsf routine\n') > sys.stderr.flush() > > errors = [] > if request.method == 'POST': > if not request.POST.get('cycle', ''): > errors.append('Missing cycle number for read snap. Please > enter a value of 1 through 6 for cycle.') > else: > cycle = request.POST.get('cycle', '') > rclist = runReadSnap(cycle) > > if 0 == rclist[0]: > return HttpResponseRedirect('/after_rs/') > else: > errors.append('Read snap transfer failed with ' + > rclist[1]) > > return render_to_response('rsf.html', {'errors': errors}) > > def after_rs(request): > return render_to_response('after_rs.html') > > > On Nov 8, 3:46 pm, Daniel Roseman <dan...@roseman.org.uk> wrote: >> On Nov 8, 5:54 pm, octopusgrabbus <old_road_f...@verizon.net> wrote: >> >> > I am able to log into my form page, which is a simple form asking the >> > user for one value. If that value is entered successfully, I am able >> > to redirect to another "you were successful" page. However, my >> > template logic that checks to see if the user is authenticated -- as >> > far as I can tell the user is logged using Django's admin resources -- >> > says the user is not authenticated. >> >> > How is a user's being authenticated cached, so another html template >> > knows that fact? >> >> It's not 'cached'. A user's logged-in status is identified via their >> session cookie, which is sent to the server on every request and >> processed via the authentication middleware. >> >> However, I suspect your problem is simpler. Are you sure you are >> passing the request, or the user, to the second template? It would >> help if you posted the code for the relevant view and template. >> -- >> DR. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.