I recently came back to a project I put on hold for a couple weeks,
and after updating the Django trunk, all my references to
"request.user.id" are broken. Here is an example view for a rating
widget:

1 @login_required
2 def rate(request, song_id):
3     song = get_object_or_404(Song, pk=song_id)
4     if 'rating' not in request.GET or request.GET['rating'] not in
range(1,5):
5         HttpResponseRedirect(song.get_absolute_url())
6     rating = Rating.objects.get_or_create(user__pk=request.user.id,
song__pk=song.id)
7     rating.rating = int(request.GET['rating'])
8     rating.save()
9     return HttpResponseRedirect(song.get_absolute_url())

This throws an "IntegrityError" if the user is logged in, presumably
complaining that request.user.id is NULL (at line 6). But it passes
the @login_required constraint just fine. I'm having similar problems
with other views that use request.user.

Does anyone know if the user API has recently changed? I've scoured
the latest online documentation, and can't seem to find any alternate
way to access the ID of the currently logged in user. Any help is
appreciated.
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to