File: utilities.rst

package info (click to toggle)
python-django-extensions 4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,820 kB
  • sloc: python: 18,601; javascript: 7,354; makefile: 108; xml: 17
file content (33 lines) | stat: -rw-r--r-- 739 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Utilities
=========

:synopsis: Other utility functions or classes


InternalIPS
-----------

`InternalIPS` allows to specify CIDRs for `INTERNAL_IPS` settings parameter.

Example `settings.py`::

  from django_extensions.utils import InternalIPS

  INTERNAL_IPS = InternalIPS([
      "127.0.0.1",
      "172.16.0.0/16",
  ])

Use `sort_by_size` to sort the lookups to search the largest subnet first.

Example `settings.py`::

  from django_extensions.utils.internal_ips import InternalIPS

  INTERNAL_IPS = InternalIPS([
      "127.0.0.1",
      "172.16.0.0/16",
  ], sort_by_size=True)

`InternalIPS` is inspired by `netaddr.IPSet` please consider using it instead as
it is more optimized but requires the additional `netaddr` package.