userobj = User.objects.get(username=myuser)

Will get you a User object or throw an error if it can't find anything. The
string representation of the User object is the string contained its
username field.

Try this to confirm:
type(userobj)
On 6 Jan 2015 18:48, "Henry Versemann" <fencer1...@gmail.com> wrote:

> I currently using Python 2.7.7 and Django 1.7 as I build a new application.
> I need to retrieve an entire User object from the authentication User
> Model, but when I do the following:
>
> userobj = User.objects.get(username=myuser)
>
> all I'm getting returned is just the same username value (contained in
> myuser) that I'm trying to use, to get the complete associated User object.
> So my question is what am I doing wrong?
> Can't I use a regular query on the User model (that I get from this
> import: "from django.contrib.auth.models import User" ) the same way that I
> would be able to use on one of my application's models?
> This is very frustrating and while I'm comfortable with using Django
> apparently I still have a lot to learn about it.
> Thanks for the help.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b9f1b941-d01b-402a-94e9-33b2dbd13dbe%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/b9f1b941-d01b-402a-94e9-33b2dbd13dbe%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BWjgXOs5-apZnuisBRHs1FAH5XygrLFnvcm2aQ65nVfG65NGw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to