Fixes #136: Trigger error on prefix w/host bits set instead of silently converting it
This commit is contained in:
@@ -10,7 +10,13 @@ from .lookups import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def prefix_validator(prefix):
|
||||||
|
if prefix.ip != prefix.cidr.ip:
|
||||||
|
raise ValidationError("{} is not a valid prefix. Did you mean {}?".format(prefix, prefix.cidr))
|
||||||
|
|
||||||
|
|
||||||
class BaseIPField(models.Field):
|
class BaseIPField(models.Field):
|
||||||
|
default_validators = [prefix_validator]
|
||||||
|
|
||||||
def python_type(self):
|
def python_type(self):
|
||||||
return IPNetwork
|
return IPNetwork
|
||||||
|
Reference in New Issue
Block a user