Hi all,
I need your help on this.

Suddenly this weekend my templates on my Win XP box started breaking
with the error message:
TemplateSyntaxError at /vr/isi/items/
Caught an exception while rendering: invalid literal for int() with
base 10: ''

The template line causing the problem is:
<th> {{ flt_cy_average|floatformat }} </th>

If I check the value of flt_cy_average it is:
'flt_cy_average': 1.2436554207945787

If I hardcode the variable to a string with a comma delimiter it
passes without error:
flt_cy_average = '1,24'

I'm running the code on Windows XP, Swedish version and the same code
is working on an Ubuntu server without any problems. Is the problem
that the template engine is picking up my Swedish locale and how do I
change this.

I'm running Django revision 9526 and mod_python through Apache 2.2.

I've set:
USE_I18N = False
and tried:
import locale
locale.setlocale(locale.LC_ALL,'C')
but it doesn't help.

I've also tried to reverse to an old Django version, but it doesn't
help either.

Can anyone give me a hint on what's going on here? Is there a setting
where I can tell the template engine to expect decimal points for
floats?

Thanks for any help; traceback (on reverted Django version) below,
Ulf

-------
Environment:

Request Method: POST
Request URL: http://localhost/vr/isi/items/
Django Version: 1.1 pre-alpha SVN-9526
Python Version: 2.5.2
Installed Applications:
['vr.isi',
 'vr.org',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.admin',
 'django.contrib.admindocs']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware')


Template error:
In template c:\web\vr\templates\isi\items\items.html, error at line
108
   Caught an exception while rendering: invalid literal for int() with
base 10: ''



   102 :                 <th> {{ int_publications_count_frac }}  </th>


   103 :                 <td>Fractionalised based on the number of
author addresses</td>


   104 :             </tr>


   105 :             <tr>


   106 :                 <th> Average number of citations per
publication and year </th>


   107 :                 <td>c<sub>y</sub></td>


   108 :                 <th>  {{ flt_cy_average|floatformat }}  </td>


   109 :                 <td> Open citation window, self-citations
removed (based on author name matching)</td>


   110 :             </tr>


   111 :             <tr>


   112 :                 <th> Share of publications cited above year
threshold {{ obj_config.flt_citation_significant_threshold }} </th>


   113 :                 <td>p<sub>yt</sub></td>


   114 :                 <th>
{{ dct_summary_data.publication_share_over_threshold_uso|
floatformat:"0" }}% </th>


Traceback:
File "C:\Program\Python25\lib\site-packages\django\core\handlers
\base.py" in get_response
  86.                 response = callback(request, *callback_args,
**callback_kwargs)
File "C:\web\vr\isi\views.py" in items_analysis
  809.     return render_to_response(template, locals())
File "C:\Program\Python25\lib\site-packages\django\shortcuts
\__init__.py" in render_to_response
  18.     return HttpResponse(loader.render_to_string(*args,
**kwargs), **httpresponse_kwargs)
File "C:\Program\Python25\lib\site-packages\django\template\loader.py"
in render_to_string
  107.     return t.render(context_instance)
File "C:\Program\Python25\lib\site-packages\django\template
\__init__.py" in render
  176.         return self.nodelist.render(context)
File "C:\Program\Python25\lib\site-packages\django\template
\__init__.py" in render
  768.                 bits.append(self.render_node(node, context))
File "C:\Program\Python25\lib\site-packages\django\template\debug.py"
in render_node
  71.             result = node.render(context)
File "C:\Program\Python25\lib\site-packages\django\template
\loader_tags.py" in render
  97.         return compiled_parent.render(context)
File "C:\Program\Python25\lib\site-packages\django\template
\__init__.py" in render
  176.         return self.nodelist.render(context)
File "C:\Program\Python25\lib\site-packages\django\template
\__init__.py" in render
  768.                 bits.append(self.render_node(node, context))
File "C:\Program\Python25\lib\site-packages\django\template\debug.py"
in render_node
  71.             result = node.render(context)
File "C:\Program\Python25\lib\site-packages\django\template
\loader_tags.py" in render
  97.         return compiled_parent.render(context)
File "C:\Program\Python25\lib\site-packages\django\template
\__init__.py" in render
  176.         return self.nodelist.render(context)
File "C:\Program\Python25\lib\site-packages\django\template
\__init__.py" in render
  768.                 bits.append(self.render_node(node, context))
File "C:\Program\Python25\lib\site-packages\django\template\debug.py"
in render_node
  71.             result = node.render(context)
File "C:\Program\Python25\lib\site-packages\django\template
\loader_tags.py" in render
  24.         result = self.nodelist.render(context)
File "C:\Program\Python25\lib\site-packages\django\template
\__init__.py" in render
  768.                 bits.append(self.render_node(node, context))
File "C:\Program\Python25\lib\site-packages\django\template\debug.py"
in render_node
  71.             result = node.render(context)
File "C:\Program\Python25\lib\site-packages\django\template
\defaulttags.py" in render
  245.                     return self.nodelist_true.render(context)
File "C:\Program\Python25\lib\site-packages\django\template
\__init__.py" in render
  768.                 bits.append(self.render_node(node, context))
File "C:\Program\Python25\lib\site-packages\django\template\debug.py"
in render_node
  81.             raise wrapped

Exception Type: TemplateSyntaxError at /vr/isi/items/
Exception Value: Caught an exception while rendering: invalid literal
for int() with base 10: ''

Original Traceback (most recent call last):
  File "C:\Program\Python25\lib\site-packages\django\template
\debug.py", line 71, in render_node
    result = node.render(context)
  File "C:\Program\Python25\lib\site-packages\django\template
\debug.py", line 87, in render
    output = force_unicode(self.filter_expression.resolve(context))
  File "C:\Program\Python25\lib\site-packages\django\template
\__init__.py", line 559, in resolve
    new_obj = func(obj, *arg_vals)
  File "C:\Program\Python25\lib\site-packages\django\template
\defaultfilters.py", line 170, in floatformat
    exp = Decimal('1.0') / (Decimal(10) ** abs(p))
  File "C:\Program\Python25\Lib\decimal.py", line 1155, in __div__
    op2 = _WorkRep(other)
  File "C:\Program\Python25\Lib\decimal.py", line 4676, in __init__
    self.int = int(value._int)
ValueError: invalid literal for int() with base 10: ''

-------------------------------------

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to