I looked a lot but I couldn’t find a way to return my model to django admin with the columns not only the model name:
What I wish to accomplish from my model is to have the fields represent as columns in django admin, such as it is in users:
I have a model called Products:
from django.db import models
# Create your models here.
class Product(models.Model):
title = models.CharField(max_length=30, null=False, blank=False)
price = models.FloatField(null=False, blank=False)
description = models.CharField(max_length=250, null=False, blank=False)
longDescription = models.TextField(max_length=900, null=True, blank=True)
def __str__(self):
return self.title
It’s register on admin site so I can see it as:
I’m looking for a way to have my products listed as users, with the id, price, description as columns… Is it possible?
Thanks in advance!
>Solution :
You should fill ModelAdmin.list_display for your ProductAdmin like this
class ProductAdmin(ModelAdmin):
list_display = ['id', 'price', 'description']

