Opened 16 years ago

Closed 16 years ago

Last modified 16 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: 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 vung, 16 years ago

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 by Malcolm Tredinnick, 16 years ago

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 by Malcolm Tredinnick, 16 years ago

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 by Malcolm Tredinnick, 16 years ago

(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 by (none), 16 years ago

milestone: post-1.0

Milestone post-1.0 deleted

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