oscarmlage / django-cruds-adminlte

django-cruds is simple drop-in django app that creates CRUD for faster prototyping
BSD 3-Clause "New" or "Revised" License
425 stars 81 forks source link

displays link to image instead of the actually image itself. #54

Closed igabice closed 6 years ago

igabice commented 6 years ago

hello, thanks for this wonderful app, it saved me a lot time. I have a model with an imageField, i would like to display the actual image but instead i get the name of the image in both the list and detail view and only when the name is clicked can i see the image. please how can i make the image display in both list and detail view?

luisza commented 6 years ago

Hi, I am not sure if this work, but you can overwrite the get_FOO_display https://docs.djangoproject.com/en/2.0/ref/models/instances/#django.db.models.Model.get_FOO_display

django-cruds-adminlte first check if get_FOO_display if found call this function.

oscarmlage commented 6 years ago

Hmm, for the list you can just extend the templates/cruds/columns/filefield.html or change a bit the code (PR is welcome!) and create a custom field for the images (something like imagefield would be really nice).

For the detail view we're using the html from django-image-cropping (https://github.com/jonasundderwolf/django-image-cropping) so, I think the right way is to look for how to extend it in the docs of the project.

Please keep me updated with the progress.

igabice commented 6 years ago

i added the code below in the filefield.html located at cruds_adminlte/templates/cruds/columns/filefield.html the image now displays in list view but i only get the link when in detail view.

<img src="{{ object.image.url }}" alt="image" style="width:400px; max-height:600px" />

oscarmlage commented 6 years ago

Yeah @igabice that is a solution, but instead to add code to filefield.html you can create your own one and put the code there. Or even better, as I've said above, create a imagefield type and put the code in a imagefield.html and PR ;).

For the detail view you should take a look to the django-image-cropping project.

TBH would be a really nice feature to have imagefield as field type (list) and the widget (detail) with the html in our project, just to not depend on others. Let's see if we can add it in next release.