Opened 11 years ago

Closed 11 years ago

#7249 closed (invalid)

Better code for 7535 fix

Reported by: leotr Owned by: nobody
Component: contrib.admin Version: master
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


-                    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)

1.diff (1.2 KB) - added by leotr 11 years ago.

Download all attachments as: .zip

Change History (4)

Changed 11 years ago by leotr

Attachment: 1.diff added

comment:1 Changed 11 years ago by leotr

comment:2 Changed 11 years ago by leotr

Triage Stage: UnreviewedDesign decision needed

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.

comment:3 Changed 11 years ago by leotr

Resolution: invalid
Status: newclosed

Invalid after changeset 7536

Note: See TracTickets for help on using tickets.
Back to Top