Skip to content

Admin issue: admin/silver/provider: 'unicode' object has no attribute 'items' #634

@jeromecc

Description

@jeromecc

Hello!

I am using django-silver version 0.7.0 installed through pip with Django 1.11, Python 2.7.

The admin is working well with one exception: when I try to see the list of providers in the admin, I get this error.

http://127.0.0.1:8008/admin/silver/provider/
AttributeError
'unicode' object has no attribute 'items'
/home/elkcloner/.virtualenvs/copper/local/lib/python2.7/site-packages/silver/admin.py in metadata, line 68

In template /home/elkcloner/.virtualenvs/copper/local/lib/python2.7/site-packages/django/contrib/admin/templates/admin/base.html, error at line 75
75 {% block object-tools %}{% endblock %}

Seems related to this piece of code in silver/admin.py

def metadata(obj):
    d = u'(None)'
    if obj.meta:
        d = u''
        for key, value in obj.meta.items():
            d += u'%s: <code>%s</code><br>' % (escape(key), escape(value))
    return d
metadata.allow_tags = True

The url http://127.0.0.1:8008/admin/silver/provider/1/ works normally.

A bit more debug info (i am using the default provider sample from the documentation)

site-packages/django/contrib/admin/utils.py in lookup_field:
289. value = attr(obj)
attr | <function metadata at 0x7f6bf1e7c938>
model_admin | <silver.admin.ProviderAdmin object at 0x7f6bf1e36890>
name | <function metadata at 0x7f6bf1e7c938>
obj | <Provider: Presslabs (Presslabs SRL)>
opts |

site-packages/silver/admin.py in metadata
68. for key, value in obj.meta.items():
d | u''
obj | <Provider: Presslabs (Presslabs SRL)>

I have no idea what's going on other than the object looks like it is a string and not a dictionary, so it doesn't have an items() method.

Thanks for your input.
jérôme

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions