Skip to content

Commit

Permalink
Auto-fill the "author" field
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Nov 14, 2013
1 parent 7b11b9c commit 80a7f41
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions elephantblog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,9 @@ class EntryAdmin(item_editor.ItemEditor):
}],
item_editor.FEINCMS_CONTENT_FIELDSET,
]

def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == 'author':
kwargs['initial'] = request.user.id
return super(EntryAdmin, self).formfield_for_foreignkey(
db_field, request, **kwargs)

0 comments on commit 80a7f41

Please sign in to comment.