Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Displaying dicts in the admin console does not render nicely #4532

Closed
5 tasks done
alexk307 opened this issue Oct 3, 2016 · 9 comments
Closed
5 tasks done

Displaying dicts in the admin console does not render nicely #4532

alexk307 opened this issue Oct 3, 2016 · 9 comments
Labels
Milestone

Comments

@alexk307
Copy link
Contributor

alexk307 commented Oct 3, 2016

Checklist

  • I have verified that that issue exists against the master branch of Django REST framework.
  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • This is not a usage question. (Those should be directed to the discussion group instead.)
  • This cannot be dealt with as a third party library. (We prefer new functionality to be in the form of third party libraries where possible.)
  • I have reduced the issue to the simplest possible case.
  • [] I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)

There is no template code for displaying dicts in the admin console. Ideally this should mimic some of other templates for the admin console as to display the dict in a nice way.

@rocktavious
Copy link

FWIW - I use this template override for templates/rest_framework/admin/dict_value.html

{% load rest_framework %}
<table class="table table-striped">
  <tbody>
    {% for key, value in value.items %}
      <tr>
        <th>{{ key|format_value }}</th>
        <td>{{ value|format_value }}</td>
      </tr>
    {% endfor %}
  </tbody>
</table>

@alexk307
Copy link
Contributor Author

That should work fix the issue. I think all that's needed is a template, and this looks like it'll do the job.

@rocktavious
Copy link

I also changed the templates/rest_framework/admin/list_value.html
to give it a little bit better view when working with nested dictionaries

{% load rest_framework %}
  {% for item in value %}
  <div class="well">
      {{ item|format_value }}
  </div>
  {% endfor %}

i found the well class from bootstrap did a better job then using another table with an auto incremented index value

example:
screen shot 2016-10-27 at 12 26 44 pm

@tomchristie
Copy link
Member

Looks promising. Pull requests welcome. Otherwise will review this in due course.

@alexk307
Copy link
Contributor Author

@rocktavious happy to do it if you don't want to!

@rocktavious
Copy link

Currently don't have the bandwidth - still trying to upgrade all our projects at work to DRF 3.5 and have alot of things to fixup. So if you got the time and drive feel free to take it over @alexk307 !

@alexk307
Copy link
Contributor Author

@rocktavious I'll take care of it. Cheers!

alexk307 pushed a commit to alexk307/django-rest-framework that referenced this issue Oct 29, 2016
alexk307 pushed a commit to alexk307/django-rest-framework that referenced this issue Oct 29, 2016
@alexk307 alexk307 mentioned this issue Oct 29, 2016
@alexk307
Copy link
Contributor Author

took a stab here: #4636

@tomchristie
Copy link
Member

Closed via #4636 - great stuff!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants