Skip to content

Commit

Permalink
Fix BlogPost admin page crashing when user only has view permission (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninjaclasher authored May 10, 2020
1 parent 772fed3 commit 5523fb7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion judge/admin/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ class FlatPageAdmin(VersionAdmin, OldFlatPageAdmin):
class BlogPostForm(ModelForm):
def __init__(self, *args, **kwargs):
super(BlogPostForm, self).__init__(*args, **kwargs)
self.fields['authors'].widget.can_add_related = False
if 'authors' in self.fields:
# self.fields['authors'] does not exist when the user has only view permission on the model.
self.fields['authors'].widget.can_add_related = False

class Meta:
widgets = {
Expand Down

0 comments on commit 5523fb7

Please sign in to comment.