Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install django-ipyfield

How to install django-ipyfield

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install django-ipyfield
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.1.6 Available View build log
0.1.4 Failed View build log
0.1.3 Available View build log
0.1.2 Available View build log
Windows (64-bit)
0.1.6 Available View build log
0.1.4 Failed View build log
0.1.3 Available View build log
0.1.2 Available View build log
Mac OS X (10.5+)
0.1.6 Available View build log
0.1.4 Failed View build log
0.1.3 Available View build log
0.1.2 Available View build log
Linux (32-bit)
0.1.6 Available View build log
0.1.4 Failed View build log
0.1.3 Available View build log
0.1.2 Available View build log
Linux (64-bit)
0.1.6 Available View build log
0.1.4 Failed View build log
0.1.3 Available View build log
0.1.2 Available View build log
 
Author
License
MIT
Dependencies
Imports
Lastest release
version 0.1.6 on Feb 12th, 2012

ipyfield provides a model field for django that allows the storage of an ip address as a "pretend" PositiveBigInt (currently varchar(39) until I can figure out how to get an unsigned 64bit integer column across all supported DBs) on the db side by using IPy to handle conversion to an IPy.IP instance (or None) on the python side.

Wut?

In its way, it gives us a way to store both ipv4 and ipv6 consistently without having to throw them in long charfields. Also, it gives us an easy way to validate data as it comes in, while giving us access to additional meta information (basically everything that makes IPy so awesome).

Installation

Add this to your django project by installing with pip:

pip install django-ipyfield

or with easy_install:

easy_install django-ipyfield

Usage

In your models, do something like the following:

from django.db import models
from ipyfield.models import IPyField

class MyModel(models.Model):

    # the regular params should work well enough here
    ipaddr = IPyField()
    # ... and so on

From here, any assignments to obj.ipaddr can be considered a constructor argument to a new IPy.IP instance. Anything IP() can use to make a new object can be used.

When making queries, I added one extra piece of syntactical sugar. For __in (range) lookups, you can pass a CIDR notation address range, for example:

MyModel.objects.filter(ipaddr__in='10.0.0.0/24')

Currently you need to use this form of notation supported for this kind of query. For now, if you need to use a prefix-netmask style notation, pass it to IPy.IP yourself and use the resulting instance as your filter parameter.

TODOs

  • figure out how to build an appropriately sized integer field across all DBs.

Changelog

0.1.6
Added support for gt, gte, lt, and lte lookups.
0.1.5
Added south support.
0.1.4
IPy.IP instance raises exception when compared to a non-IP instance. This becomes an issue when you get into ModelForm validation (didn't come up when only using the ORM) with regards to empty/null values. Fixed by subclassing (wrapping) IPy.IP.
0.1.3
Basic field functionality in place.

Subscribe to package updates

Last updated Feb 12th, 2012

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.