phantasmobile/app/item/admin.py

41 lines
927 B
Python
Raw Permalink Normal View History

2023-07-15 07:30:36 +00:00
from django.contrib import admin
from . import models
class ItemAdmin(admin.ModelAdmin):
search_fields = ['title', 'description', 'url']
list_display = ['__str__', 'id', 'published']
list_filter = (
("published", admin.EmptyFieldListFilter),
)
2023-07-25 19:03:54 +00:00
raw_id_fields = ['user']
def get_changeform_initial_data(self, request):
return {'user': request.user}
2023-07-15 07:30:36 +00:00
admin.site.register(models.Item, ItemAdmin)
class CommentAdmin(admin.ModelAdmin):
2023-07-16 05:56:14 +00:00
search_fields = [
'item__title',
'item__url',
'text',
'name',
'email'
]
2023-07-15 07:30:36 +00:00
list_display = ['__str__', 'published']
list_filter = (
("published", admin.EmptyFieldListFilter),
)
2023-07-25 19:03:54 +00:00
raw_id_fields = ['item', 'user']
2023-07-15 07:30:36 +00:00
admin.site.register(models.Comment, CommentAdmin)
2023-08-31 17:24:52 +00:00
class WeekAdmin(admin.ModelAdmin):
2023-08-31 17:25:26 +00:00
search_fields = ['monday', 'title']
2023-08-31 17:24:52 +00:00
admin.site.register(models.Week, WeekAdmin)