from django.contrib import admin from .models import Note from utils.widgets import AdminImageWidget, LGEntryForm from django.contrib.auth.models import User from django.contrib.admin import SimpleListFilter @admin.register(Note) class NoteAdmin(admin.ModelAdmin): def get_form(self, request, obj=None, change=False, **kwargs): form = super().get_form(request, obj=obj, change=change, **kwargs) form.base_fields['post'].queryset = Post.objects.filter( user=request.user ) return form list_display = ('date_created', 'title', 'post') search_fields = ['title'] list_filter = ['date_created'] class Media: js = ('image-loader.js', 'next-prev-links.js') css = { "all": ("my_styles.css",) }