Skip to content

Commit

Permalink
Bugfix: Add rule in admin was throwing an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
sztamas committed Aug 30, 2020
1 parent df90b18 commit 914e6de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions iprestrict/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,12 @@ class Meta:
rank = models.IntegerField(blank=True)

def __init__(self, *args, **kwargs):
super(Rule, self).__init__(*args, **kwargs)
self.ip_group = typed_ip_group(self.ip_group)
super().__init__(*args, **kwargs)
# TODO review this code, it fails without the try except when using Add rule in admin
try:
self.ip_group = typed_ip_group(self.ip_group)
except IPGroup.DoesNotExist:
pass

@property
def regex(self):
Expand Down
1 change: 1 addition & 0 deletions testsites/testsite_31/testsite_31/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

INSTALLED_APPS = [
'iprestrict',
'django_extensions',
'polls.apps.PollsConfig',
'django.contrib.admin',
'django.contrib.auth',
Expand Down

0 comments on commit 914e6de

Please sign in to comment.