A
A
aftnia112021-08-16 13:46:13
Django
aftnia11, 2021-08-16 13:46:13

What am I doing wrong when working with the Django admin panel?

I need to add a database search to the Django admin panel and make some data appear in the preview
What am I doing wrong?

from django.contrib import admin
from .models import WorkingBase
from .models import Blacklist


admin.site.register(WorkingBase)
admin.site.register(Blacklist)

class WorkingBaseAdmin(admin.ModelAdmin):
  list_display=('title', 'price3')
  search_fields=('title')


admin.site.register(WorkingBase)

When adding this code, the site crashes:
class WorkingBaseAdmin(admin.ModelAdmin):
  list_display=('title', 'price3')
  search_fields=('title')


admin.site.register(WorkingBase)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Nesterov, 2021-08-16
@aftnia11

I understand admin.py looks like this? (First block of code)

from django.contrib import admin
from .models import WorkingBase
from .models import Blacklist

admin.site.register(WorkingBase) # Первое подключение WorkingBase
admin.site.register(Blacklist)

class WorkingBaseAdmin(admin.ModelAdmin):
  list_display=('title', 'price3')
  search_fields=('title')


admin.site.register(WorkingBase) # Второе подключение WorkingBase

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question