title: Create boolean twin field automatically for Django model fields
body: <p>I have models with many fields. For a large amount of those fields (let's say around 20) but not all of them I would like to automatically create a twin <code>BooleanField</code> each.</p>
  <p>Some requirements:</p>
  <ul>
  <li>The fields are of different type (e.g. <code>CharField</code>, <code>DateField</code>, ...)</li>
  <li>In the future there will be new fields added, which is why I want to create this generic solution such that I'll only have to add the main field and mark it for adding a twin</li>
  <li>Ideally I would like to be able to use the same ORM syntax for filtering and such as if I had manually defined the boolean twin</li>
  <li>Most of the times just the fields themselves are needed, only very rarely the boolean twin</li>
  </ul>
  <p>Given the following model</p>
  <pre class="lang-py prettyprint-override"><code>from django.db.models import model
  
  class MyModel(models.Model):
      ignore_field = models.Charfield(max_length=10)
      my_field = models.Charfield(max_length=30)
  </code></pre>
  <p>I would like to automatically add the field:</p>
  <pre class="lang-py prettyprint-override"><code>    is_fixed_my_field = models.BooleanField(default=False)
  </code></pre>
  <h2>What I have considered:</h2>
  <p><strong>1. <a href="https://pypi.org/project/django-composite-field/" rel="nofollow noreferrer">composite-fields</a></strong></p>
  <p>The problem I see with that approach is that I will need to define such a composite field for every field type manually and I am also not sure if I can pass kwargs. Also, I don't think I can keep the default syntax for queries. Instead I'd have to add this additional level at every filter.</p>
  <pre class="lang-py prettyprint-override"><code>class FixedField(CompositeField):
      value = models.Charfield()  # could I even add the kwargs?
      is_fixed = models.BooleanField()
  
  class MyModel(models.Model):
      ignore_field = models.Charfield(max_length=10)
      my_field = FixedField()
  </code></pre>
  <p><strong>2. <a href="https://docs.djangoproject.com/en/dev/howto/custom-model-fields/" rel="nofollow noreferrer">custom fields</a></strong>
  My dream is to create a custom field that I could use like the following:</p>
  <pre class="lang-py prettyprint-override"><code>class MyModel(models.Model):
      ignore_field = models.Charfield(max_length=10)
      my_field = FixableField(models.Charfield, max_length=30)
  
  MyModel.objects.filter(is_fixed_my_field=True)
  m = MyModel(my_field=&quot;foo&quot;)
  print(m.is_fixed_my_field)  # False
  </code></pre>
  <p>Obviously it doesn't work with someting like</p>
  <pre class="lang-py prettyprint-override"><code>class FixableField:
      def __init__(self, model, field_class: models.Field, *args, **kwargs):
          setattr(model, f&quot;is_fixed_{cannot_get_the_field_name}&quot;, models.BooleanField)
          field_class(*args, **kwargs)
  </code></pre>
  <p>because the class isn't really instantiated during migration generation as far as I understand.</p>
  <p><strong>Is my dream possible at all?</strong></p>
  <p><em>Note1: I'm using postgres in the background.</em></p>
  <p><em>Note2: I'm currently using Django 1.11, but if a solution only works with a more recent version I am interested in that too.</em></p>