I want to create a custom field such that if the field is queried, then the filter is always __iexact.
Example:
class Domain(models.Model):
domain = models.IExactCharField()
name = models.CharField()
I want a query like Domain.objects.filter('domain=newdomain')
to be rewritten as Domain.objects.filter('domain__iexact=newdomain')
.
I understand you can do this with a custom manager, but I want adding the field to add the custom manager. And if a custom manager is already defined, I want the managers functionality to be chained. Is this possible? I was looking at the contribute_to_class
method and thought it might have some potential when defining the field.