I would use the create_user[1] function, then you can just enter the
password, instead of the hash value. Might make your code a little
more readable.

Alex

[1]http://docs.djangoproject.com/en/dev/topics/auth/#creating-users

On Jan 6, 3:19 pm, Phlip <[email protected]> wrote:
> > Google cannot find any traffic on this topic, so I'm warming up the
> > question here before researching it myself. If I figure out how to
> > write login_as() for tests, I will post it here.
>
> Do I always have to see the same hands??
>
>         from django.contrib.auth.models import User
>         hell_yeah = True
>
>         u = User.objects.create(username=u'admin', is_active=True,
> email=u'[email protected]',
>                                 is_superuser=hell_yeah, is_staff=True,
>                                 password=u'sha1$e34de
> $49632495b9ab78a54ff53a0d1145e2b9e8eb2af6')
>
>         self.client.login(username='admin', password='admin') # <--
> the money line
>
>         self.get('/shop-admin/')  #  TODO  get should demand a 200
>
> Some of you might see fit to put that User into a reusable (but test-
> only) JSON file... to each her or his own.
>
>
>
> > --
> >   Phlip
> >  http://twitter.com/Pen_Bird
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
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