]> git.p6c8.net - pcdenotes.git/blobdiff - notes/admin.py
Automatically select the current user when creating a note
[pcdenotes.git] / notes / admin.py
index 2dd4171e9e26ad0d7436d52a29b4d334121d2133..7272afb8854308d00d42ae28bb771a030b8908bd 100644 (file)
@@ -9,4 +9,9 @@ class NoteAdmin(admin.ModelAdmin):
     search_fields = ('title', 'content',)
     prepopulated_fields = {'slug': ('title',)}
 
+    def get_form(self, request, obj=None, **kwargs):
+        form = super(NoteAdmin, self).get_form(request, obj, **kwargs)
+        form.base_fields['author'].initial = request.user
+        return form
+
 admin.site.register(Note, NoteAdmin)
\ No newline at end of file

patrick-canterino.de