S
S
Susanin2021-07-10 17:15:03
Django
Susanin, 2021-07-10 17:15:03

How to add models to the admin panel?

Hello! Added display of my model in the admin panel:
60e9a41219621145726471.png

But on the edit page, a void is displayed with the inscription:
60e9a311af64e952150789.jpeg

Please tell me where I could make a mistake and how to fix it.

admin.py code:

from django.contrib import admin
from shop.models import Product

admin.site.register(Product)


models.py code:
from django.db import models

class Product(models.Model):
    visible = models.BooleanField(default=True)
    sdescr = models.CharField(max_length=40)
    ldescr = models.CharField(max_length=200, null=True)
    cost = models.IntegerField()
    class Meta:
        verbose_name_plural = 'Продукты'
        verbose_name = 'Продукты'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-07-10
@ivan1234554321

It is necessary to register the relationship of the model with the successor of ModelAdmin, and not the model.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question