>             return HttpResponse(user.id)           #just to test
>
> it returns error
> MOD_PYTHON ERROR
> TypeError: argument 1 must be string or read-only buffer, not long
> besides all that long error page

That's because HttpResponse expects a string (or read-only buffer) and
you've provided it a long int. Django stores all primary keys (like
user.id) as long ints. Try converting to a string:

return HttpResponse(str(user.id))

> now if i use
>             uu=User.objects.filter(username='dd')
>             return HttpResponse(uu.id)      #i used email and others also
> it shows
> Exception Type:         AttributeError
> Exception Value:        'QuerySet' object has no attribute 'id'

And that's failing because uu is a QuerySet, not a User. In this
particular case you're probably better off using get() instead of
filter(), so that you get access to the User object directly:

uu = User.objects.get(username='dd')
return HttpResponse(str(uu.id))

Note that get() will throw an error if you have two Users with the
same username (but I don't think the User model allows duplicate
usernames; this is more something to keep in mind if you wish to use
the same syntax elsewhere).


--~--~---------~--~----~------------~-------~--~----~
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