Specifying a mySQL ENUM in a Django model
<p>How do I go about specifying and using an ENUM in a Django model?</p>

<p>From the <a href="https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.choices" rel="nofollow">Django documentation</a>:</p>

<pre><code>MAYBECHOICE = (
    ('y', 'Yes'),
    ('n', 'No'),
    ('u', 'Unknown'),
)
</code></pre>

<p>And you define a charfield in your model :</p>

<pre><code>married = models.CharField(max_length=1, choices=MAYBECHOICE)
</code></pre>

<p>You can do the same with integer fields if you don't like to have letters
in your db.</p>

<p>In that case, rewrite your choices:</p>

<pre><code>MAYBECHOICE = (
    (0, 'Yes'),
    (1, 'No'),
    (2, 'Unknown'),
)
</code></pre>
