mardi 29 avril 2014

Django - KeyError capturés tandis que rendu : u'minutes' - Stack Overflow


when I try to acced to /admin/djcelery/taskstate/ in django app it return this error how can I solve this error


  Template error:
In template c:\python27\lib\site-packages\django\contrib\admin\templates\admin \change_list.html, error at line 95
Caught KeyError while rendering: u'minutes'
85 : {% endif %}
86 : {% endblock %}
87 :
88 : <form id="changelist-form" action="" method="post"{% if cl.formset.is_multipart %} enctype="multipart/form-data"{% endif %}>{% csrf_token %}

89 : {% if cl.formset %}
90 : {{ cl.formset.management_form }}
91 : {% endif %}
92 :
93 : {% block result_list %}
94 : {% if action_form and actions_on_top and cl.full_result_count %}{% admin_actions %}{% endif %}

error line 95 !!!


  95 :            {% result_list cl %} 

96 : {% if action_form and actions_on_bottom and cl.full_result_count %}{% admin_actions %}{% endif %}

97 : {% endblock %}
98 : {% block pagination %}{% pagination cl %}{% endblock %}
99 : </form>
100 : </div>

101 : </div>

102 : {% endblock %}



This unicode error is very common in Django. You need to either convert into string what you are sending from back-end or parse it in the front end. In backend do str(x) of the value that is getting the error in front end. i.e in you case minutes.




The problem is that there is a bug in the pypi version that is already fixed in github. In the current pypi package (format is in humanize.py in line 64):


return ungettext(
_('{minutes} minute ago'),
_('{minutes} minutes ago'), minutes
).format(minutes)

This doesn't work, it would have to be {0} instead of {minutes}. In the master branch in github that's already fixed:


return ungettext(
_('{minutes} minute ago'),
_('{minutes} minutes ago'), minutes
).format(minutes=minutes)

I would suggest just using the github version, you can pip install the most current commit like this:


pip install -e "git+git://github.com/celery/django-celery.git@b6eeb8952594a7f8073901db613801f2ac544cd7#egg=django-celery"

If you leave the commit id out, it will always install the current head, but it's safer to use a specific commit in case there are breaking changes.



when I try to acced to /admin/djcelery/taskstate/ in django app it return this error how can I solve this error


  Template error:
In template c:\python27\lib\site-packages\django\contrib\admin\templates\admin \change_list.html, error at line 95
Caught KeyError while rendering: u'minutes'
85 : {% endif %}
86 : {% endblock %}
87 :
88 : <form id="changelist-form" action="" method="post"{% if cl.formset.is_multipart %} enctype="multipart/form-data"{% endif %}>{% csrf_token %}

89 : {% if cl.formset %}
90 : {{ cl.formset.management_form }}
91 : {% endif %}
92 :
93 : {% block result_list %}
94 : {% if action_form and actions_on_top and cl.full_result_count %}{% admin_actions %}{% endif %}

error line 95 !!!


  95 :            {% result_list cl %} 

96 : {% if action_form and actions_on_bottom and cl.full_result_count %}{% admin_actions %}{% endif %}

97 : {% endblock %}
98 : {% block pagination %}{% pagination cl %}{% endblock %}
99 : </form>
100 : </div>

101 : </div>

102 : {% endblock %}


This unicode error is very common in Django. You need to either convert into string what you are sending from back-end or parse it in the front end. In backend do str(x) of the value that is getting the error in front end. i.e in you case minutes.



The problem is that there is a bug in the pypi version that is already fixed in github. In the current pypi package (format is in humanize.py in line 64):


return ungettext(
_('{minutes} minute ago'),
_('{minutes} minutes ago'), minutes
).format(minutes)

This doesn't work, it would have to be {0} instead of {minutes}. In the master branch in github that's already fixed:


return ungettext(
_('{minutes} minute ago'),
_('{minutes} minutes ago'), minutes
).format(minutes=minutes)

I would suggest just using the github version, you can pip install the most current commit like this:


pip install -e "git+git://github.com/celery/django-celery.git@b6eeb8952594a7f8073901db613801f2ac544cd7#egg=django-celery"

If you leave the commit id out, it will always install the current head, but it's safer to use a specific commit in case there are breaking changes.


0 commentaires:

Enregistrer un commentaire