Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

django admin image

from django.utils.html import format_html

@admin.register(Model1) 
class Model1Admin(admin.ModelAdmin):

    def image_tag(self, obj):
        return format_html('<img src="{}" />'.format(obj.image.url))

    image_tag.short_description = 'Image'

    list_display = ['image_tag',]
Comment

django show image in admin page

in main URL:

from django.conf import settings
from django.conf.urls.static import static

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Comment

PREVIOUS NEXT
Code Example
Python :: django all urls 
Python :: pythion code for finding all string lengths in a code 
Python :: export csv from dataframe python 
Python :: how to get what type of file in python 
Python :: pyspark correlation 
Python :: find null value for a particular column in dataframe 
Python :: how to duplicate columns pandas 
Python :: Install Basemap on Python 
Python :: how to record pyttsx3 file using python 
Python :: tkinter gui grid and frame 
Python :: django sort queryset 
Python :: store all files name in a folder python 
Python :: hot reloading flask 
Python :: CUDA error: device-side assert triggered 
Python :: powershell get list of groups and members 
Python :: pandas display only certain columns 
Python :: savefig resolution 
Python :: install python3 6 ubuntu 20 
Python :: how to edit variables with functions in python 
Python :: 13 digit timestamp python 
Python :: df drop column 
Python :: python shuffle list with seed 
Python :: python numpy arrays equal 
Python :: python time in nanoseconds 
Python :: how to define dtype of each column before actually reading csv file 
Python :: python drop axis 
Python :: how to rotate plot in jupyter 
Python :: python write txt utf8 
Python :: run git pull from python script 
Python :: user nextcord interactions 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =