Opened 17 years ago
Closed 17 years ago
#7249 closed (invalid)
Better code for 7535 fix
Reported by: | leotr | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Design decision needed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
- users = list(User.objects.filter(email=username)) - if len(users) == 1: - user = users[0] - else: - # Either we cannot find the user, or if more than 1 - # we cannot guess which user is the correct one. - raise User.DoesNotExist()
I think that mine is more elegant. Just add AssertionError
to exception list.
Attachments (1)
Change History (4)
by , 17 years ago
comment:1 by , 17 years ago
comment:2 by , 17 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
Note:
See TracTickets
for help on using tickets.
In other words i don't see a reason to evaluate a query and then check the length of list. The
AssertionError
is raised when more than 1 object exist.