There are many ways to achieve what you need.
What I would do is to define net_cidr
as a models.CharField
.
Then define a modelform for your model where you are going to implement
the clean_net_cidr
function.
class CIDRForm(ModelForm):
def clean_net_cidr(self):
# do your magic processing here
class Meta:
model = CIDR
and then pass that form to the model admin object
class CIDRAdmin(admin.ModelAdmin):
form = CIDRForm
UPDATE:
It seems this is exactly what you need, based on your comments. https://github.com/jimfunk/django-postgresql-netfields
Among other fields, it includes a CidrAddressField