Hello.
In a nutshell:
It appears the validator applied to a GenericIPAddressField form field
doesn't allow an IP address with a netmask.
But saving the same thing to a PostgreSQL database via a model works just
fine.
As far as I can tell, both model and form fields use the same validators?
Is this somehow expected?
class IPAddressList(models.Model):
address = models.GenericIPAddressField()
class IPAddressListForm(ModelForm):
class Meta:
model = IPAddressList
exclude = []
ip_address = "
127.0.0.1/8"
o = IPAddressList.objects.create(address=ip_address)
print o.address
#
127.0.0.1/8
But then:
form = IPAddressListForm({"address": ip_address})
form.is_valid()
print form.errors
# <ul class="errorlist"><li>address<ul class="errorlist"><li>Enter a valid
IPv4 or IPv6 address.</li></ul></li></ul>
I'm using Django 1.8.
I keep looking for stupid mistakes I might have made. Suggestions welcome.
--
Best regards/vennlig hilsen
Hans S. Tømmerholt
Application Developer, Hosting, Global IT
Opera Software