I'm trying to display inline uploaded images in "Change List" page in Django Admin:
This is my code below:
# "models.py"
from django.db import models
class Product(models.Model):
name = models.CharField(max_length=50)
price = models.DecimalField(decimal_places=2, max_digits=5)
def __str__(self):
return self.name
class ProductImage(models.Model):
product = models.ForeignKey(Product, on_delete=models.CASCADE)
image = models.ImageField()
def __str__(self):
return self.image.url
# "admin.py"
from django.contrib import admin
from .models import Product
class ProductImageInline(admin.TabularInline):
model = ProductImage
@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
inlines = (ProductImageInline,)
So, how can I display inline uploaded images in "Change" page in Django Admin?