Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#9773 closed (fixed)

float argument required when using redirect_to in simple.py

Reported by: kauu@… 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: UI/UX:

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 Changed 8 years ago by vung

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Resolution: worksforme
Status: newclosed

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/'}),
)

comment:2 Changed 8 years ago by Malcolm Tredinnick

Component: UncategorizedDocumentation
Resolution: worksforme
Status: closedreopened

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 Changed 8 years ago by Malcolm Tredinnick

Resolution: fixed
Status: reopenedclosed

(In [9626]) Documented how to handle '%' characters in redirect_to() URL strings (even in
the absence of keyword arguments). Fixed #9773.

comment:4 Changed 8 years ago by Malcolm Tredinnick

(In [9627]) [1.0.X] Documented how to handle '%' characters in redirect_to() URL strings
(even in the absence of keyword arguments). Fixed #9773.

Backport of r9626 from trunk.

comment:5 Changed 8 years ago by (none)

milestone: post-1.0

Milestone post-1.0 deleted

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