#9773 closed (fixed)
float argument required when using redirect_to in simple.py
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Documentation | Version: | 1.0 |
| Severity: | Keywords: | redirect_to | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Exception 'float argument required ' occurs when i call the redirect_to method which in Simple.py in case of the url contain Chinese or Japanese.
url containing Chinese looks like "%E8%AF%95%E8%AF%95%E5%9C%B0%E4%B8%A"。
i guest that the parameter in line 35 will put kwargs's value to %E , so , the exception occurs.
34 if url is not None: 35 return HttpResponsePermanentRedirect(url % kwargs)
so, how can fix it ???
Change History (5)
comment:1 by , 17 years ago
| Resolution: | → worksforme |
|---|---|
| Status: | new → closed |
comment:2 by , 17 years ago
| Component: | Uncategorized → Documentation |
|---|---|
| Resolution: | worksforme |
| Status: | closed → reopened |
We should document that this is needed. The original problem description isn't "worksforme" at all and people bump into it from time to time. It needs an explicit change to their code.
comment:3 by , 17 years ago
| Resolution: | → fixed |
|---|---|
| Status: | reopened → closed |
Just double the percent signs to prevent string interpolation:
urlpatterns = patterns('django.views.generic.simple', ('^foo/$', 'redirect_to', {'url': '/%%E8%%AF%%95%%E8%%AF%%95%%E5%%9C%%B0/'}), )