[Django]-Django 1.1.1: How should I store an empty IP address using PostgreSQL?

2👍

If you can convince the devs to accept one of the patches, I’d say just run a patched copy of Django until the patched version lands. If not, then it might be less headache to just use a sentinel value, as you suggested, even though it is a hack. You might also just use a regular CharField instead of an IPAddressField, but then you get stuck having to maintain validation logic on your own.

1👍

Have you tried just using blank=True for nexthop, rather than both blank=True and null=True? As noted in the Django docs:

Only use null=True for non-string fields such as integers, booleans and dates.

👤mipadi

0👍

And what about using empty string as sentinel, instead of 255.255.255.255 ?

As admin back-end stores empty field as empty string (when blank=true), this solution has the advantage to be transparent for the user and doesn’t force him to use a faked value…

Leave a comment