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
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/op.x4k9a1179xbofn%40hanst-laptop.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment