Skip to content

Commit 4d3fb52

Browse files
committed
fields: support subnet masks via ip_address
1 parent 10e97f1 commit 4d3fb52

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mirrors/fields.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
from django.core.exceptions import ValidationError
44
from django.db import models
55

6-
from ipaddress import ip_address as IP
6+
from ipaddress import ip_address, ip_interface
7+
8+
def IP(address):
9+
if '/' not in address:
10+
return ip_address(address)
11+
return ip_interface(address)
712

813
class IPNetworkFormField(forms.Field):
914
def to_python(self, value):

0 commit comments

Comments
 (0)