Code

Opened 5 years ago

Closed 5 years ago

Last modified 5 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 ???

Attachments (0)

Change History (5)

comment:1 Changed 5 years ago by vung

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to 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/'}),
)

comment:2 Changed 5 years ago by mtredinnick

  • Component changed from Uncategorized to Documentation
  • Resolution worksforme deleted
  • Status changed from closed to 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 Changed 5 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from reopened to closed

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

comment:4 Changed 5 years ago by mtredinnick

(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 5 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.