Advertisement
horozov86

admin.py for app destination

Mar 25th, 2024
733
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. from django.contrib import admin
  2. from .models import Place
  3.  
  4. @admin.register(Place)
  5. class PlaceAdmin(admin.ModelAdmin):
  6.     list_display = ('name', 'location', 'rating', 'category', 'user')
  7.     list_filter = ('category', 'rating')
  8.     search_fields = ('name', 'location')
  9.     ordering = ('name', '-rating')
  10.  
  11.     actions = ['custom_action']
  12.  
  13.     fieldsets = (
  14.         (None, {
  15.             'fields': ('name', 'description', 'location', 'rating', 'image_url', 'category', 'user')
  16.         }),
  17.         ('Advanced options', {
  18.             'classes': ('collapse',),
  19.             'fields': ('field_name',),
  20.         }),
  21.     )
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement