allisson / django-pagseguro2

Integração da API v2 do PagSeguro com o Django.
MIT License
95 stars 44 forks source link

Erro no admin do modelo Checkout #1

Closed hozano closed 10 years ago

hozano commented 10 years ago

Olá. Primeiramente gostaria de parebenizar pelo trabalho. Ficou muito boa a app e ajudou bastante na integração do meu site. Inclusive foi mais fácil que o pagseguro.

Entretanto, tive um problema ao acessar o objeto checkout pelo admin do django. Gostaria de saber como posso resolver esse problema.

Segue o erro abaixo: Environment:

Request Method: GET Request URL: http://localhost:8000/sys/admin/pagseguro/checkout/21/

Django Version: 1.7 Python Version: 2.7.6

Template error: In template /usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/contrib/admin/templates/admin/change_form.html, error at line 21 coercing to Unicode: need string or buffer, int found 11 : {% block coltype %}colM{% endblock %} 12 : 13 : {% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} change-form{% endblock %} 14 : 15 : {% if not is_popup %} 16 : {% block breadcrumbs %} 17 :

23 : {% endblock %} 24 : {% endif %} 25 : 26 : {% block content %}
27 : {% block object-tools %} 28 : {% if change %}{% if not is_popup %} 29 :
    30 : {% block object-tools-items %} 31 :
  • Traceback: File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/handlers/base.py" in get_response

    1. response = response.render() File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/response.py" in render
    2. self.content = self.rendered_content File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/response.py" in rendered_content
    3. content = template.render(context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/base.py" in render
    4. return self._render(context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/base.py" in _render
    5. return self.nodelist.render(context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/base.py" in render
    6. bit = self.render_node(node, context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/debug.py" in render_node
    7. return node.render(context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/loader_tags.py" in render
    8. return compiled_parent._render(context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/base.py" in _render
    9. return self.nodelist.render(context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/base.py" in render
    10. bit = self.render_node(node, context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/debug.py" in render_node
    11. return node.render(context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/loader_tags.py" in render
    12. return compiled_parent._render(context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/base.py" in _render
    13. return self.nodelist.render(context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/base.py" in render
    14. bit = self.render_node(node, context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/debug.py" in render_node
    15. return node.render(context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/defaulttags.py" in render
    16. return nodelist.render(context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/base.py" in render
    17. bit = self.render_node(node, context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/debug.py" in render_node
    18. return node.render(context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/loader_tags.py" in render
    19. result = block.nodelist.render(context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/base.py" in render
    20. bit = self.render_node(node, context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/debug.py" in render_node
    21. return node.render(context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/defaulttags.py" in render
    22. return nodelist.render(context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/base.py" in render
    23. bit = self.render_node(node, context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/debug.py" in render_node
    24. return node.render(context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/debug.py" in render
    25. output = self.filter_expression.resolve(context) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/base.py" in resolve
    26. new_obj = func(obj, *arg_vals) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/template/defaultfilters.py" in _dec
    27. args[0] = force_text(args[0]) File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/utils/encoding.py" in force_text
    28. s = six.text_type(s)

    Exception Type: TypeError at /sys/admin/pagseguro/checkout/21/ Exception Value: coercing to Unicode: need string or buffer, int found

allisson commented 10 years ago

Olá hozano,

Eu ainda não fiz os testes dessa lib com o django-1.7, vou fazer esses testes assim que possível.

Obrigado por abrir essa issue.

hozano commented 10 years ago

Allisson, acabei encontrando uma solução para resolver o problema. Ele aconteceu pq o str do modelo Checkout tá retornando um inteiro na linha 49 do models.py. Nesse caso eu modifiquei a linha para: return unicode(self.pk)

Isso resolveu o problema :)

[]s

allisson commented 10 years ago

Eu vou lançar uma nova versão com suporte para django 1.7 :smile: