Re: Getting current user id

2008-01-07 Thread Alex Koshelev
obj.user_id = request.user.id # this is too really? On 7 янв, 12:55, Collin Grady <[EMAIL PROTECTED]> wrote: > On Jan 6, 1:36 pm, Darthmahon <[EMAIL PROTECTED]> wrote: > > > When I used request.user, it outputs the username of the currently > > logged in user. When I try and use this as part of

Re: Getting current user id

2008-01-07 Thread Collin Grady
On Jan 6, 1:36 pm, Darthmahon <[EMAIL PROTECTED]> wrote: > When I used request.user, it outputs the username of the currently > logged in user. When I try and use this as part of the entry into the > table, it won't let me as it's expecting an integer. You are mistaken. When /printing/ the user o

Re: Getting current user id

2008-01-06 Thread Florian Apolloner
The error message: Invalid value: 'user' should be a instance, not a clearly states you should use a User-instance and not an integer (long). You might wanna show us some code... And yes printing request.user reuturns the username, but that's caused by __unicode__ and has nothing to to with th

Re: Getting current user id

2008-01-06 Thread Darthmahon
When I used request.user, it outputs the username of the currently logged in user. When I try and use this as part of the entry into the table, it won't let me as it's expecting an integer. Is that wrong? On Jan 6, 9:33 pm, Florian Apolloner <[EMAIL PROTECTED]> wrote: > You are doing something l

Re: Getting current user id

2008-01-06 Thread Florian Apolloner
You are doing something like my_instance.author = request.user.id whereas you should do: my_instance.author = request.user. Why? You are working with the Django ORM and it doesn't expect you to give it an User-Id (although it get's saved as that in the db), but an instance of django.contrib.auth.m

Re: Getting current user id

2008-01-06 Thread Darthmahon
Thanks, should have guessed that! For some reason though it is returning the value as 11L. I just want it to return 11, as it is throwing up an error when trying to use it like that: Invalid value: 'user' should be a instance, not a I'm using a MySQL database, any way of stripping the L off t

Re: Getting current user id

2008-01-06 Thread Alex Koshelev
User id - request.user.id On 6 янв, 23:43, Darthmahon <[EMAIL PROTECTED]> wrote: > Hi Guys, > > Been looking to get the current id of the user logged in everywhere > but can't seem to find how to do this. > > Basically in my views.py file I want to insert an entry into a table. > Part of this ins

Getting current user id

2008-01-06 Thread Darthmahon
Hi Guys, Been looking to get the current id of the user logged in everywhere but can't seem to find how to do this. Basically in my views.py file I want to insert an entry into a table. Part of this insert requires the current logged in users id. The only bit of information I seem to be able to