Specifying a mySQL ENUM in a Django model

前端 未结 9 1795
说谎
说谎 2020-12-12 17:16

How do I go about specifying and using an ENUM in a Django model?

9条回答
  •  时光取名叫无心
    2020-12-12 17:42

    There're currently two github projects based on adding these, though I've not looked into exactly how they're implemented:

    1. Django-EnumField:
      Provides an enumeration Django model field (using IntegerField) with reusable enums and transition validation.
    2. Django-EnumFields:
      This package lets you use real Python (PEP435-style) enums with Django.

    I don't think either use DB enum types, but they are in the works for first one.

提交回复
热议问题