python - django - using a flag on each model field
<p>I want to build a simple moderation system for my application.I have a class in my application models like this:</p>

<pre><code>#models.py
class TableName(models.Model):
        is_qualified = False
        title = models.CharField(max_length=300, blank=False)
        description = models.TextField(max_length=500, default="DEFAULT VALUE")  
        video = models.FileField(upload_to='somepath')
        picture_thumbnail = models.ImageField(upload_to='somepath')
</code></pre>

<p>I have 3 questions:</p>

<ol>
<li>How can I add <code>is_qualified</code> to every field in my model and setting it to <code>False</code> as default?</li>
<li>How can I write a view method first for checking if admin checked an object (for example title or description) and used its checkbox to change field's <code>is_qualified</code> value to <code>True</code>?</li>
<li>How to add a checkbox for each object in admin area for using that view method?</li>
</ol>

<p>Thank you very much.</p>

<p>Hmm, adding is_qualified for each field would be a bit too much.</p>

<p>If your are using postgresql I would consider using <a href="https://github.com/djangonauts/django-hstore" rel="nofollow">django-hstore</a>, where you can dynamically add key-value fields. </p>

<p>Using this package, you can make something like your field name as a key, and True/False as a value.</p>

<p>Then when trying to validate is your object "qualified" you just make something like this:</p>

<p><code>is_valid = all([value for key, value in your_hstore_field.items()])</code></p>

<hr>

<p>EDIT</p>

<pre><code>class TableName(models.Model):
        is_qualified = models.BooleanField(default=False)
        title = models.CharField(max_length=300, blank=False)
        description = models.TextField(max_length=500, default="DEFAULT VALUE")  
        video = models.FileField(upload_to='somepath')
        picture_thumbnail = models.ImageField(upload_to='somepath')
        data = hstore.DictionaryField()
</code></pre>

<p>Then you can have some custom function like this:</p>

<pre><code>def update_qualified(obj_instance):
    if all(value for key, value in obj_instance.data.items()):
        obj_instance.is_qualified = True
    else:
        obj_instance.is_qualified = False
    obj_instance.save()
</code></pre>

python django