boxed / django-fastdev

An app to make it safer, faster and more fun to develop in Django
BSD 3-Clause "New" or "Revised" License
169 stars 14 forks source link

`User.objects.get(4)` should give a good error message #11

Open boxed opened 2 years ago

boxed commented 2 years ago

The current error in django is:

TypeError: cannot unpack non-iterable int object

If you do User.objects.get('123') you get:

ValueError: too many values to unpack (expected 2)
Marlysson commented 2 years ago

What error message should be shown?

boxed commented 2 years ago

Maybe something like:

"Got 4, but get/filter takes keyword arguments or Q objects. Maybe you meant pk=4?"

boxed commented 2 years ago

I think the check that should be made is that none of the *args should be non-Q-objects.