README 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. Django PostgreSQL Netfilters
  2. ============================
  3. This project is an attempt at making proper Django net related fields for Django
  4. Currently the built in IPAddressField does not support IPv6 and uses an inefficient
  5. HOST() cast in all lookups. Hopefully there experience from this project can lead
  6. to a resolution of these issues upstream.
  7. In addition to the basic IPAddressField replacement a CIDR and MAC field have
  8. been added. Furthermore a customer Manager allows for access to all of PostgreSQL's
  9. INET operators.
  10. Django version
  11. --------------
  12. Currently this code has only been tested against 1.0.x due to the Django
  13. version used by the related project that initiated this effort.
  14. Getting started
  15. ---------------
  16. Make sure netfields is in your PYTHONPATH, then simply use the following:
  17. from netfields import InetAddressField, NetManager
  18. class Example(models.Model):
  19. inet = InetAddressField()
  20. ...
  21. objects = NetManager()
  22. The page also provides CidrAddressField and a MACAddressField. NetManger is
  23. required for the extra lookups to be available. Lookups for INET and CIDR
  24. database types will be handled differently than when running vanilla Django.
  25. All lookups are case-insensitive and text based lookups are avoided whenever
  26. possible. In addition to Django's default lookup types the following have been
  27. added.
  28. __net_contained
  29. __net_contained_or_equal
  30. __net_contains
  31. __net_contains_or_equals
  32. These correspond with the operators from
  33. http://www.postgresql.org/docs/8.3/interactive/functions-net.html
  34. netfields does not have to be in INSTALLED_APPS.