On 18-6-2012 9:52, Laurence MacNeill wrote:
> well -- I hit the wrong key and posted that before I was finished typing... 
> 
> here's what's in my views.py file:
> def index(request)
>      current_username = os.environ['REMOTE_USER']

And you're sure this works? Try:
 return django.shortcuts.render_to_response(current_username)

here to verify it's coming through. Normally, the authenticated username
would be part of the request dictionary.

> This should provide me with their username (yes I do have 'import os' at 
> the top of the file)...
> 
> Now, after I get their username I want to do something like this (but I'm 
> not sure how to write in django -- so I've put ## around the pseudo-code)
>      try:
>          student = Student.objects.get(student_name=current_username)
>      except (#can't find it in Student database, but I don't know what code 
> to put here#)

It's in tutorial part 3:
https://docs.djangoproject.com/en/1.4/intro/tutorial03/#raising-404

except Student.DoesNotExist:
       student = None

>      #here's where I'm not sure how to continue -- I want to do something 
> like this#
>      #if student is defined#
>           return render_to_response('ta/student.html', student)

Almost correct:
if student is not None :
     # the student.html template will now have a variable named student
     # which is the student object you fetched
     return render_to_response('ta/student.html', student=student)
elif instructor is not None :
     #etc

-- 
Melvyn Sopacua

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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.

Reply via email to