ipregistry-django 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,356 @@
1
+ Metadata-Version: 2.4
2
+ Name: ipregistry-django
3
+ Version: 1.0.0
4
+ Summary: Official Django integration for the Ipregistry IP geolocation and threat data API.
5
+ Keywords: django,geoip,geolocation,ip,ip-address,ip-data,ip-geolocation,ipregistry,middleware,proxy-detection,threat-data,vpn-detection
6
+ Author: Ipregistry
7
+ Author-email: Ipregistry <support@ipregistry.co>
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Environment :: Web Environment
12
+ Classifier: Framework :: Django
13
+ Classifier: Framework :: Django :: 5.2
14
+ Classifier: Framework :: Django :: 6.0
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Topic :: Internet :: WWW/HTTP
24
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
+ Requires-Dist: django>=5.2
26
+ Requires-Dist: ipregistry>=5.0.0,<6.0.0
27
+ Requires-Python: >=3.10
28
+ Project-URL: Changelog, https://github.com/ipregistry/ipregistry-django/blob/main/CHANGELOG.md
29
+ Project-URL: Documentation, https://ipregistry.co/docs
30
+ Project-URL: Homepage, https://ipregistry.co
31
+ Project-URL: Issues, https://github.com/ipregistry/ipregistry-django/issues
32
+ Project-URL: Source, https://github.com/ipregistry/ipregistry-django
33
+ Description-Content-Type: text/markdown
34
+
35
+ # Ipregistry Django
36
+
37
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
38
+ [![CI](https://github.com/ipregistry/ipregistry-django/actions/workflows/ci.yml/badge.svg)](https://github.com/ipregistry/ipregistry-django/actions/workflows/ci.yml)
39
+ [![PyPI](https://img.shields.io/pypi/v/ipregistry-django.svg)](https://pypi.org/project/ipregistry-django/)
40
+
41
+ The official Django integration for the [Ipregistry](https://ipregistry.co) IP geolocation
42
+ and threat data API, built on top of [`ipregistry`](https://github.com/ipregistry/ipregistry-python).
43
+
44
+ ```python
45
+ def view(request):
46
+ if request.ipregistry and request.ipregistry.location.country.code == "FR":
47
+ ...
48
+ ```
49
+
50
+ ## Features
51
+
52
+ - **`request.ipregistry`** — geolocation and threat data anywhere a request is in scope,
53
+ queried at most once per request and only when actually accessed.
54
+ - **Middleware and view decorators** to block countries (451) or threats such as proxies,
55
+ Tor and VPNs (403), site-wide or per-view.
56
+ - **Django caching** — repeated visits from the same IP cost a single credit, backed by
57
+ any configured cache (Redis, Valkey, Memcached, ...).
58
+ - **GDPR helper** — `is_eu(request)` to decide when to show consent banners.
59
+ - **Safe by default** — fails open on API errors, never sends private IPs, never logs
60
+ full IP addresses, supports async views and ASGI.
61
+ - **Testable** — `fake_ipregistry()` stubs lookups with zero HTTP and records assertions.
62
+ - **`manage.py ipregistry_lookup`** command and Django system checks for misconfiguration.
63
+
64
+ ## Requirements
65
+
66
+ - Django 5.2+ (5.2 LTS and 6.0 are tested)
67
+ - Python 3.10+
68
+
69
+ ## Installation
70
+
71
+ ```console
72
+ pip install ipregistry-django
73
+ ```
74
+
75
+ Set your API key ([get one here](https://dashboard.ipregistry.co)), preferably via the
76
+ environment:
77
+
78
+ ```console
79
+ export IPREGISTRY_API_KEY=YOUR_API_KEY
80
+ ```
81
+
82
+ Then enable the app and middleware in `settings.py`:
83
+
84
+ ```python
85
+ INSTALLED_APPS = [
86
+ # ...
87
+ "ipregistry_django",
88
+ ]
89
+
90
+ MIDDLEWARE = [
91
+ # ...
92
+ "ipregistry_django.middleware.IpregistryMiddleware",
93
+ ]
94
+ ```
95
+
96
+ That's it. Every view (and everything downstream of the middleware) can now read
97
+ `request.ipregistry`.
98
+
99
+ ## Usage
100
+
101
+ ### Request data
102
+
103
+ `request.ipregistry` is a lazy [`IpInfo`](https://ipregistry.co/docs/responses) object.
104
+ The API is only queried when the attribute is first accessed, at most once per request:
105
+
106
+ ```python
107
+ def checkout(request):
108
+ info = request.ipregistry
109
+ if info:
110
+ currency = info.currency.code
111
+ country = info.location.country.name
112
+ is_vpn = info.security.is_vpn
113
+ ```
114
+
115
+ On lookup failure (or when the client IP is private and no `DEVELOPMENT_IP` is set),
116
+ `request.ipregistry` evaluates to `None`-like falsy and the exception is available at
117
+ `request.ipregistry_error`. Prefer truthiness checks (`if request.ipregistry:`) over
118
+ `is None` because of the lazy wrapper — or call `get_ipregistry(request)` directly:
119
+
120
+ ```python
121
+ from ipregistry_django import get_ipregistry
122
+
123
+ info = get_ipregistry(request) # plain IpInfo or None, memoized, never raises
124
+ ```
125
+
126
+ ### Async views
127
+
128
+ ```python
129
+ from ipregistry_django import aget_ipregistry
130
+
131
+ async def view(request):
132
+ info = await aget_ipregistry(request)
133
+ ```
134
+
135
+ ### Direct lookups
136
+
137
+ For lookups outside the request cycle (Celery tasks, shell, ...), use the module-level
138
+ functions — they share the configured client and cache, and raise on failure:
139
+
140
+ ```python
141
+ import ipregistry_django
142
+
143
+ response = ipregistry_django.lookup_ip("54.85.132.205")
144
+ print(response.data.location.country.name)
145
+
146
+ response = ipregistry_django.batch_lookup_ips(["8.8.8.8", "1.1.1.1"])
147
+ response = ipregistry_django.lookup_asn(42)
148
+ response = ipregistry_django.parse_user_agent("Mozilla/5.0 ...")
149
+ response = ipregistry_django.origin_lookup_ip()
150
+ ```
151
+
152
+ ### Blocking countries
153
+
154
+ Site-wide, with middleware:
155
+
156
+ ```python
157
+ MIDDLEWARE = [
158
+ # ...
159
+ "ipregistry_django.middleware.BlockCountriesMiddleware",
160
+ ]
161
+
162
+ IPREGISTRY = {
163
+ "BLOCK_COUNTRIES": ["KP", "SY"], # or ALLOW_COUNTRIES for an allow-list
164
+ }
165
+ ```
166
+
167
+ Per-view, with decorators:
168
+
169
+ ```python
170
+ from ipregistry_django.decorators import allow_countries, block_countries
171
+
172
+ @block_countries("KP", "SY")
173
+ def view(request): ...
174
+
175
+ @allow_countries("DE", "FR")
176
+ def eu_only_view(request): ...
177
+ ```
178
+
179
+ Blocked visitors receive a `451 Unavailable For Legal Reasons` response. Visitors whose
180
+ country cannot be determined pass through (fail-open).
181
+
182
+ ### Blocking threats
183
+
184
+ ```python
185
+ MIDDLEWARE = [
186
+ # ...
187
+ "ipregistry_django.middleware.BlockThreatsMiddleware",
188
+ ]
189
+
190
+ IPREGISTRY = {
191
+ "BLOCK_THREATS": ["proxy", "tor", "vpn"], # optional extra signals
192
+ }
193
+ ```
194
+
195
+ ```python
196
+ from ipregistry_django.decorators import block_threats
197
+
198
+ @block_threats("proxy", "tor")
199
+ def view(request): ...
200
+ ```
201
+
202
+ IPs flagged as threats, attackers or abusers are always blocked with a `403`. Anonymizing
203
+ services (`anonymous`, `proxy`, `relay`, `tor`, `vpn`) are opt-in signals.
204
+
205
+ For class-based views, use Django's `method_decorator`:
206
+
207
+ ```python
208
+ from django.utils.decorators import method_decorator
209
+
210
+ @method_decorator(block_threats("vpn"), name="dispatch")
211
+ class CheckoutView(View): ...
212
+ ```
213
+
214
+ ### GDPR / EU detection
215
+
216
+ ```python
217
+ from ipregistry_django import is_bot, is_eu, is_threat
218
+
219
+ if is_eu(request, assume_eu=True): # assume EU when unknown: show the banner
220
+ ...
221
+
222
+ if is_threat(request, proxy=True, tor=True):
223
+ ...
224
+
225
+ if is_bot(request): # User-Agent heuristic, no API call, no credits
226
+ ...
227
+ ```
228
+
229
+ ### Templates
230
+
231
+ Add the context processor to render lookup data directly in templates:
232
+
233
+ ```python
234
+ TEMPLATES = [{
235
+ "OPTIONS": {
236
+ "context_processors": [
237
+ # ...
238
+ "ipregistry_django.context_processors.ipregistry",
239
+ ],
240
+ },
241
+ }]
242
+ ```
243
+
244
+ ```html
245
+ {% if ipregistry %}Hello, visitor from {{ ipregistry.location.country.name }}!{% endif %}
246
+ ```
247
+
248
+ ## Configuration
249
+
250
+ All settings live in a single optional `IPREGISTRY` dict. Defaults shown:
251
+
252
+ ```python
253
+ IPREGISTRY = {
254
+ "ALLOW_COUNTRIES": [], # allow-list for BlockCountriesMiddleware
255
+ "API_KEY": "", # falls back to the IPREGISTRY_API_KEY env var
256
+ "BASE_URL": None, # None: default endpoint, "eu": EU endpoint, else verbatim
257
+ "BLOCK_COUNTRIES": [], # deny-list for BlockCountriesMiddleware
258
+ "BLOCK_THREATS": [], # extra signals for BlockThreatsMiddleware
259
+ "CACHE": True, # cache lookups with Django's cache framework
260
+ "CACHE_ALIAS": "default", # which CACHES alias to use
261
+ "CACHE_KEY_PREFIX": "ipregistry",
262
+ "CACHE_TTL": 600, # seconds
263
+ "CLIENT_IP_HEADER": None, # e.g. "X-Forwarded-For" or "CF-Connecting-IP"
264
+ "DEVELOPMENT_IP": None, # public IP to use when the client IP is private
265
+ "EXEMPT_PATHS": None, # blocker-exempt path prefixes; None: STATIC_URL/MEDIA_URL
266
+ "FAIL_OPEN": True, # False: blockers answer 503 on lookup failure
267
+ "FIELDS": None, # e.g. "ip,location,security" to lower payload size
268
+ "HOSTNAME": False, # resolve reverse DNS hostnames (extra credits)
269
+ "RETRIES": 1,
270
+ "RETRY_INTERVAL": 1.0,
271
+ "RETRY_ON_SERVER_ERROR": True,
272
+ "RETRY_ON_TOO_MANY_REQUESTS": False,
273
+ "TIMEOUT": 5, # seconds
274
+ }
275
+ ```
276
+
277
+ `API_KEY` and `BASE_URL` also read the `IPREGISTRY_API_KEY` and `IPREGISTRY_BASE_URL`
278
+ environment variables when not set explicitly.
279
+
280
+ ### Client IP and reverse proxies
281
+
282
+ By default the client IP comes from `REMOTE_ADDR`. Behind a reverse proxy or CDN, set
283
+ `CLIENT_IP_HEADER` to the header your proxy controls — never one clients can spoof:
284
+
285
+ ```python
286
+ IPREGISTRY = {"CLIENT_IP_HEADER": "CF-Connecting-IP"} # Cloudflare
287
+ IPREGISTRY = {"CLIENT_IP_HEADER": "X-Forwarded-For"} # nginx with a correct set_real_ip
288
+ ```
289
+
290
+ The first *public* address found wins. Private and reserved addresses are never sent to
291
+ the API; during local development, set `DEVELOPMENT_IP` to a fixed public IP so lookups
292
+ work from localhost.
293
+
294
+ ### Caching
295
+
296
+ Lookups are cached in the `CACHE_ALIAS` Django cache for `CACHE_TTL` seconds (keys are
297
+ hashed, so any backend works, including Memcached). On top of that, results are memoized
298
+ per request, so accessing `request.ipregistry` repeatedly costs nothing.
299
+
300
+ ### EU endpoint
301
+
302
+ To ensure requests are handled by Ipregistry nodes hosted in the EU only:
303
+
304
+ ```python
305
+ IPREGISTRY = {"BASE_URL": "eu"}
306
+ ```
307
+
308
+ ### Errors
309
+
310
+ `request.ipregistry`, `get_ipregistry()`, guards, middleware and decorators never raise —
311
+ they fail open and log to the `"ipregistry"` logger (with anonymized IPs). Set
312
+ `"FAIL_OPEN": False` to have the blocking middleware and decorators answer `503` when a
313
+ lookup fails. The direct lookup functions raise `ipregistry.ApiError` /
314
+ `ipregistry.ClientError`.
315
+
316
+ Run `python manage.py check` to surface configuration problems (missing API key, unknown
317
+ setting keys, invalid country codes or threat signals, unknown cache alias).
318
+
319
+ ## Testing your app
320
+
321
+ `fake_ipregistry` swaps the shared client for a stub — no HTTP, private test-client IPs
322
+ allowed:
323
+
324
+ ```python
325
+ from ipregistry_django.testing import fake_ipregistry
326
+
327
+ def test_french_visitor(client):
328
+ stubs = {"*": {"location": {"country": {"code": "FR", "name": "France"}}}}
329
+ with fake_ipregistry(stubs) as fake:
330
+ response = client.get("/")
331
+ assert "Bienvenue" in response.text
332
+ fake.assert_looked_up("127.0.0.1")
333
+ ```
334
+
335
+ Stub specific IPs, `"*"` for any IP, `"origin"` for origin lookups; values can be dicts,
336
+ `IpInfo` instances or exceptions. Assertions include `assert_looked_up`,
337
+ `assert_looked_up_times`, `assert_not_looked_up`, `assert_nothing_looked_up`,
338
+ `assert_origin_looked_up` and `assert_user_agents_parsed`.
339
+
340
+ ## Management command
341
+
342
+ ```console
343
+ python manage.py ipregistry_lookup # this machine's public IP
344
+ python manage.py ipregistry_lookup 8.8.8.8 1.1.1.1 # one or more IPs
345
+ python manage.py ipregistry_lookup 8.8.8.8 --fields ip,location --hostname
346
+ ```
347
+
348
+ ## Resources
349
+
350
+ - [Ipregistry documentation](https://ipregistry.co/docs)
351
+ - [Response fields](https://ipregistry.co/docs/responses)
352
+ - [Python SDK](https://github.com/ipregistry/ipregistry-python)
353
+
354
+ ## License
355
+
356
+ [Apache License 2.0](LICENSE)