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.models.User, which maps to the django users
table. request.user would be such an instance :)

On Jan 6, 10:08 pm, Darthmahon <[EMAIL PROTECTED]> wrote:
> 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 <class
> 'django.contrib.auth.models.User'> instance, not a <type 'long'>
>
> I'm using a MySQL database, any way of stripping the L off the end?
>
> On Jan 6, 9:00 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote:
>
> > 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 insert requires the current logged in users id. The only
> > > bit of information I seem to be able to retrieve is the username like
> > > so:
>
> > > request.user.username
>
> > > Is there a way of getting the current id of the logged in user?
>
> > > Thanks,
> > > Chris
--~--~---------~--~----~------------~-------~--~----~
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