Skip to content

Commit

Permalink
fields: support subnet masks via ip_address
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyapol committed Aug 4, 2020
1 parent 10e97f1 commit 4d3fb52
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mirrors/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
from django.core.exceptions import ValidationError
from django.db import models

from ipaddress import ip_address as IP
from ipaddress import ip_address, ip_interface

def IP(address):
if '/' not in address:
return ip_address(address)
return ip_interface(address)

class IPNetworkFormField(forms.Field):
def to_python(self, value):
Expand Down

0 comments on commit 4d3fb52

Please sign in to comment.