Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#20624 closed Uncategorized (needsinfo)

Truncatechars add empty space char at the beginning of the string

Reported by: stefano.vergani.it@… Owned by: nobody
Component: Template system Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi, I am using Dj 1.4.2 and I am having this is issue with truncate chars: when the value exceeds the char limit I set the result of truncating has a leading white space that wasn't there in the first place.

In the template:

<input type="hidden" id="donate_progetto" value="{{ progetto.denominazione|truncatechars:40 }}"/>

Output:

 <input type="hidden" id="donate_progetto" value=" CORREGGIO. Torre Civica - Completame..."/>

If i remove runcatechars the result is the following

Output:

 <input type="hidden" id="donate_progetto" value="CORREGGIO. Torre Civica - Completamento intervento di riparazione e consolidamento, successivo alla messa in sicurezza"/>

Change History (3)

comment:1 by Baptiste Mispelon, 12 years ago

Component: UncategorizedTemplate system
Resolution: needsinfo
Status: newclosed

Hi,

I tried several versions of django (including 1.4.2) but could not reproduce your issue.

Here's the code I used:

from django import template

s = "CORREGGIO. Torre Civica - Completamento intervento di riparazione e consolidamento, successivo alla messa in sicurezza"
t = template.Template('{{ s|truncatechars:40 }}')
print t.render(template.Context({'s': s}))

This doesn't print any leading space.

I'm going to mark this ticket as needsinfo. Please reopen it with some additional information that could help us track down the issue (in particular, is progetto.denominazione some kind of special object?).

Thanks

comment:2 by anonymous, 12 years ago

Thanks for the reply, I opened a new ticket with more info here : https://code.djangoproject.com/ticket/20626#ticket

comment:3 by Baptiste Mispelon, 12 years ago

Please don't create a new ticket, this makes it hard to track the conversation.

Instead, you can reopen this ticket (in the "Modify Ticket" tab).

Before reopening this one, could you isolate the problem a bit further?
Having a simple bit of code that demonstrates your issue will make a ticket get fixed much quicker.
Your project has a lot of code and is mostly written in a language I don't understand, which makes it hard to confirm if there really is a bug here.

For reference, here's the text of your other ticket that I closed:

This ticket is the continuation of: https://code.djangoproject.com/ticket/20624

As it was marked as needsinfo I add the following:
the source is available on GitHub here ​https://github.com/DeppSRL/open_ricostruzione

The template where the issue was happening is

​> https://github.com/DeppSRL/open_ricostruzione/blob/master/open_ricostruzione/templates/progetto.html

on line 20

Thanks.

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