Skip to content

TypeError: %u format: a real number is required, not dict #1047

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

Open
sentry-io bot opened this issue Nov 7, 2024 · 2 comments
Open

TypeError: %u format: a real number is required, not dict #1047

sentry-io bot opened this issue Nov 7, 2024 · 2 comments

Comments

@sentry-io
Copy link

sentry-io bot commented Nov 7, 2024

Sentry Issue: DJANGO-GIRLS-WEBSITE-71

TypeError: %u format: a real number is required, not dict
(13 additional frame(s) were not displayed)
...
  File "core/views.py", line 138, in year_2016_2017
    return render(
@ZubairAli999
Copy link

ZubairAli999 commented Jan 27, 2025

The TypeError: %u format: a real number is required, not dict error occurs when you're attempting to use a format specifier %u (unsigned integer) with an argument that is not a valid number, such as a dictionary.

1 :- To fix this issue, you need to:
Locate the error in the core/views.py file, line 138.
2:- Review the render() function call.
Identify where the %u formatting is being used and inspect the variable(s) being passed to it.
Ensure the argument matches the expected type.

kindly check code file

code (2).txt

@amakarudze
Copy link
Contributor

amakarudze commented Mar 28, 2025

Thanks for your suggestions, @ZubairAli999. The view works fine for en and other locales and doesn't need fixing. This is only happening because the de translations for templates/core/2015.html and templates/core/2016-2017.html did not escape %, where we have percentages causing the errors for /de/2015/ and /de/2016-2017/ urls when the gettext function is called.

For example, 71% should be escaped as 71%% so that it is treated as a string and not a string interpolation, where the template expects a value to be passed to it.

@marksweb, may you please alert the team responsible for German translations of this issue?

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

No branches or pull requests

2 participants