Created
October 6, 2012 17:26
-
-
Save ptone/3845524 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> from django.contrib.auth.models import User | |
>>> u = User.objects.all()[0] | |
>>> u | |
<User: preston> | |
>>> u.natural_key | |
<bound method User.natural_key of <User: preston>> | |
>>> u.natural_key() | |
(u'preston',) | |
>>> nat_key = u.natural_key() | |
>>> User.objects.get_by_natural_key(nat_key) | |
Traceback (most recent call last): | |
File "<input>", line 1, in <module> | |
File "/Users/preston/Projects/code/forks/django/django/contrib/auth/models.py", line 184, in get_by_natural_key | |
return self.get(username=username) | |
File "/Users/preston/Projects/code/forks/django/django/db/models/manager.py", line 131, in get | |
return self.get_query_set().get(*args, **kwargs) | |
File "/Users/preston/Projects/code/forks/django/django/db/models/query.py", line 366, in get | |
% self.model._meta.object_name) | |
DoesNotExist: User matching query does not exist. | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment