You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
I think it's because meta fields are silently expected to be dicts, but they are actually using JSONField, so they can also contain lists, strings, numbers and what else is valid JSON.
In this situation, this could be handled by checking the type of the content of the meta field.
Checking for the list type and displaying the list elements with <code>%s</code>, similary to the already implemented dict case, should be in order. Any other type can remain unformated.
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.
Seems related to this piece of code in silver/admin.py
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)
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
The text was updated successfully, but these errors were encountered: