i'm having trouble displaying images on my Djnago admin page.
i read https://stackoverflow.com/questions/2443752/how-to-display-uploaded-images-in-change-list-page-in-django-admin/51181825#51181825
this article but still didn't get what i want :(
this is my codes
models.py
from django.contrib.auth.models import (
BaseUserManager, AbstractBaseUser, PermissionsMixin
)
from django.db import models
from django.utils.html import mark_safe
class User(AbstractBaseUser, PermissionsMixin):
image = models.ImageField(
upload_to='media/profile_image/',
null=True
)
admin.py
class UserAdmin(BaseUserAdmin):
# The forms to add and change user instances
form = UserChangeForm
add_form = UserCreationForm
def image_tag(self, obj): # Here
return format_html(
f'''<a href="{obj.image.url}" target="_blank">
<img
src="{obj.image.url}" alt="{obj.image}"
width="50" height="50"
style="object-fit: cover;"
/>
</a>''')
list_display = ('uid','get_full_name', 'email', 'nickname', 'introduce','image', 'birth','is_active', 'is_superuser', 'date_joined', 'image_tag')
...
this is what i got
the image is in my PROJECTNAME/media/profile_image but i cant' display it on my admin page :(