fix: increase max_length of SubnetField for IPv6 subnets
Increased the max_length attribute of SubnetField from 43 to 45 to properly accommodate the longest possible IPv6 subnet representation. This adjustment ensures that all valid IPv6 subnets can be correctly stored, preventing potential data truncation issues.
This commit is contained in:
parent
eb50798b14
commit
245f50d0fd
1 changed files with 3 additions and 2 deletions
|
@ -1,11 +1,12 @@
|
|||
from django.db import models
|
||||
import ipaddress
|
||||
|
||||
|
||||
class SubnetField(models.CharField):
|
||||
description = "A field to store IPv4 or IPv6 subnets"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs['max_length'] = 43 # Maximum length for IPv6 with subnet
|
||||
kwargs["max_length"] = 45 # Maximum length for IPv6 with subnet
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def from_db_value(self, value, expression, connection):
|
||||
|
|
Loading…
Reference in a new issue