{"id":21094503,"url":"https://github.com/werneror/django-cidrfield","last_synced_at":"2025-10-20T09:17:05.614Z","repository":{"id":57419283,"uuid":"219126820","full_name":"Werneror/django-cidrfield","owner":"Werneror","description":"Proper CIDR fields for Django running on any database.","archived":false,"fork":false,"pushed_at":"2024-01-03T08:43:46.000Z","size":12,"stargazers_count":5,"open_issues_count":2,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-10T03:44:46.392Z","etag":null,"topics":["django","django-plugin"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Werneror.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-11-02T08:41:53.000Z","updated_at":"2024-03-07T11:52:54.000Z","dependencies_parsed_at":"2024-01-03T10:07:16.175Z","dependency_job_id":null,"html_url":"https://github.com/Werneror/django-cidrfield","commit_stats":{"total_commits":9,"total_committers":2,"mean_commits":4.5,"dds":"0.33333333333333337","last_synced_commit":"ac57c66f2347a456dadb44ba86396949b095dd48"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Werneror%2Fdjango-cidrfield","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Werneror%2Fdjango-cidrfield/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Werneror%2Fdjango-cidrfield/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Werneror%2Fdjango-cidrfield/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Werneror","download_url":"https://codeload.github.com/Werneror/django-cidrfield/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225433464,"owners_count":17473599,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","django-plugin"],"created_at":"2024-11-19T22:17:40.886Z","updated_at":"2025-10-20T09:17:05.526Z","avatar_url":"https://github.com/Werneror.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# django-cidrfield\n\n`cidrfield` provides a model field for [django](https://www.djangoproject.com) that allows the storage of an ip network on the db side by using `ipaddress` to handle conversion to an `ipaddress.ip_network` instance (or None) on the python side. It supports the use of `__contains` and `__in` to query the IP network that contain and belong to.\n\n\n## Installation\n\nAdd this to your django project by installing with pip:\n\n```\npip install django-cidrfield\n```\n\n\n## Usage\n\nIn your models, do something like the following:\n\n```\nfrom django.db import models\nfrom cidrfield.models import IPNetworkField\n\nclass MyModel(models.Model):\n\n    # the regular params should work well enough here\n    ip_network = IPNetworkField()\n    # ... and so on\n```\n\nThen you can store a ip network like the following:\n\n```\nMyModel(ip_network='192.168.1.0/24').save()\n```\n\nAnd you can query a ip network like the following:\n\n```\nMyModel.objects.filter(ip_network='192.168.1.0/24')\nMyModel.objects.filter(ip_network__contains='192.168.1.1')\nMyModel.objects.filter(ip_network__in='192.168.0.0/16')\nMyModel.objects.filter(ip_network__in=['192.168.0.0/16', '10.10.0.0/16'])\n```\n\nIf you use [DjangoQL](https://pypi.org/project/djangoql/), you can use `CIDRQLSchema` like the following:\n\n```\nfrom django.contrib import admin\nfrom djangoql.admin import DjangoQLSearchMixin\nfrom cidrfield.schemas import CIDRQLSchema\nfrom .models import MyModel\n\n\n@admin.register(MyModel)\nclass MyModelAdmin(DjangoQLSearchMixin, admin.ModelAdmin):\n    list_display = ['ip_network']\n    search_fields = ('ip_network', )\n    djangoql_schema = CIDRQLSchema\n```\n\n\n## Changelog\n\n### 0.2.1\n\n- Fix IPv6 with integers less than 2**32 being detected as IPv4.\n\n### 0.2.0\n\n- Add support for Djangoql.\n- Fixed the bug about `__in` query not supporting array.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwerneror%2Fdjango-cidrfield","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwerneror%2Fdjango-cidrfield","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwerneror%2Fdjango-cidrfield/lists"}