Skip to content

Lookups for ArrayField + InetAddressField #130

Open
@theansweris1

Description

@theansweris1

Hello. Thank you for your efforts on this package. I have a question about using lookups when combining the inet Fields with an ArrayField.

Assume we have a model like this:

from django.db import models
from django.contrib.postgres.fields import ArrayField
from netfields import InetAddressField

class Foo(models.Model):
    id = models.CharField(primary_key=True, unique=True, max_length=255)
    networks = ArrayField(InetAddressField(), null=True, blank=True)

Foo.objects.create(id="test", networks=["1.1.1.1/24", "2.2.2.2/24"])

Is there any way we can apply the provided lookups like __net_contains_or_equals in this setup?

I am basically looking for a equivalent like this SQL query:

SELECT id FROM foo WHERE '1.1.1.55' <<= ANY (networks);

Any way to do this with the ORM?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions