Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
boxed opened this issue Feb 21, 2022 · 3 comments
Open

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

boxed opened this issue Feb 21, 2022 · 3 comments
Labels
good first issue Good for newcomers

Comments

@boxed
Copy link
Owner

boxed commented Feb 21, 2022

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)
@boxed boxed added the good first issue Good for newcomers label Feb 21, 2022
@Marlysson
Copy link

What error message should be shown?

@boxed
Copy link
Owner Author

boxed commented Feb 22, 2022

Maybe something like:

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

@boxed
Copy link
Owner Author

boxed commented Feb 22, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants