Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a lookup for exact CIDR prefix length #61

Merged
merged 1 commit into from
Aug 30, 2016
Merged

Add a lookup for exact CIDR prefix length #61

merged 1 commit into from
Aug 30, 2016

Conversation

tarkatronic
Copy link
Contributor

We have fallen into a pattern of, for example: MyModel.objects.filter(network__max_prefixlen=24, network__min_prefixlen=24). To make this simpler, and allow for a single exact prefix length lookup, I've added __prefixlen. Also, as a side effect, I cleaned up the code a little bit for these lookups, making it more DRY.

@jimfunk jimfunk merged commit 9837403 into jimfunk:master Aug 30, 2016
@jimfunk
Copy link
Owner

jimfunk commented Aug 30, 2016

Thanks!

@tarkatronic tarkatronic deleted the prefixlen_lookup branch August 31, 2016 00:39
@tarkatronic
Copy link
Contributor Author

This brought to mind a thought: Instead of having 3 lookups: __prefixlen, __max_prefixlen, and __min_prefixlen, wouldn't it make sense to be able to just have a single __prefixlen and be able to chain other operations onto it? So for example you could have:

  • MyModel.objects.filter(network__prefixlen=24)
  • MyModel.objects.filter(network__prefixlen__gte=24)
  • MyModel.objects.filter(network__prefixlen__lte=24)

I don't recall the exact implementation details for something like this, but what are your thoughts?

@jimfunk
Copy link
Owner

jimfunk commented Aug 31, 2016

Yeah, that would make a lot more sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants