L
L
Les Alterman2015-12-15 16:09:10
Django
Les Alterman, 2015-12-15 16:09:10

How to display product title in Django admin panel?

95804623714d445b87b33281ff901b29.png
How to make it so that the name of this product is displayed instead of the Product object?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
mitri4, 2015-12-15
@Les_Alterman

Define the __str__() method on the model

def __str__(self):
    return self.name

S
sim3x, 2015-12-15
@sim3x

Why do you think after the name of the class

Commodity
I decided to write the answer in this way?
класс Товар(модели.Модель):
     название = модели.ТекстовоеПоле()
     №....
    
     опр __стр__(сам):
         вернуть "%с".формат(сам.название)

E
Evgeny Maltsev, 2015-12-15
@hellpirat

You can also set fields in admin.py in list_display = ('field1', 'field2', etc)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question