Custom Django model fields for ipv4 and ipv6 addresses
Djangos IPAddressField does not work properly with ipv6, and operations such as "IN" and "BETWEEN" are broken.
Also, django don't support all the operations seen on http://
A solution may be to create custom fields for inet and cidr. This will make ipv6 and regular django field operators work.
The second problem may be solved by a custom manager that supports more field operators than the default one. It will probably by hackish, but the hacks will be consentrated in one place instead of many.
Blueprint information
- Status:
- Not started
- Approver:
- None
- Priority:
- Undefined
- Drafter:
- None
- Direction:
- Needs approval
- Assignee:
- None
- Definition:
- New
- Series goal:
- None
- Implementation:
- Unknown
- Milestone target:
- None
- Started by
- Completed by
Related branches
Related bugs
Sprints
Whiteboard
An attempt has been made made to create a custom backend that subclasses the psycopg2 backend and works around the llimitations in Django's IP fields. Through this attempt is has become clear that only a field will not be a good enough solution. However a custom Manger with an appropriate WhereNode and a custom IP field with a modified get_db_prep_lookup might work.
See http://
(https:/
Since Django to the best of my knowledge does not have an easy way to distinguish how queries are made on various backends, adding custom lookup types is probably the way to go. In conformance with Django way of handling these types of new features a standalone django-
However looking at how geo-django is built should provide (and has) provided good clues as how to implement this.