]> git.p6c8.net - pcdenotes.git/blob - notes/admin.py
Automatically select the current user when creating a note
[pcdenotes.git] / notes / admin.py
1 from django.contrib import admin
2 from .models import Note
3
4 # Register your models here.
5
6 class NoteAdmin(admin.ModelAdmin):
7 list_display = ('title', 'status',)
8 list_filter = ('status',)
9 search_fields = ('title', 'content',)
10 prepopulated_fields = {'slug': ('title',)}
11
12 def get_form(self, request, obj=None, **kwargs):
13 form = super(NoteAdmin, self).get_form(request, obj, **kwargs)
14 form.base_fields['author'].initial = request.user
15 return form
16
17 admin.site.register(Note, NoteAdmin)

patrick-canterino.de