Opened 8 years ago

Closed 8 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: UI/UX:


-                    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 8 years ago.

Download all attachments as: .zip

Change History (4)

Changed 8 years ago by leotr

comment:1 Changed 8 years ago by leotr

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 8 years ago by leotr

  • Triage Stage changed from Unreviewed to Design 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 8 years ago by leotr

  • Resolution set to invalid
  • Status changed from new to closed

Invalid after changeset 7536

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