Admin Custom View Django.How

Author avatar wrote on 07/06/2022

Adding models to the admin

from django.contrib import admin
from backoffice.models import *



admin.site.register(Author)
admin.site.register(Question)
admin.site.register(Choice)

Adding Custom view to the admin

class ListingAdmin(admin.ModelAdmin):
    list_display = ('id', 'title', 'is_published', 'price', 'list_date', 'realtor')
    list_display_links = ('id', 'title')
    list_filter = ('realtor',)
    list_editable = ('is_published','price')
    search_fields = ('title', 'description', 'city', 'state')
    # readonly_fields = ["name"]
    list_per_page = 25

admin.site.register(Listing, ListingAdmin)

CRUDgen Django CRUD generator