1

I have this class in my models.py file:

class DepartmentCategory(Enum):
    """The various categories of departments"""
    committee = 'Committee'
    subcommittee = 'Subcommittee'

that is used in a selectfield for my form. All works well but when I add a new value to the Enum class eg:

class DepartmentCategory(Enum):
    """The various categories of departments"""
    general = 'General'
    committee = 'Committee'
    subcommittee = 'Subcommittee'

saving the new value the database fails and no errors are shown both in terminal and browser. I had already numerously migrated(flask db migrate) and upgraded(flask db upgrade) my database but problem not solved. Please help.

Eric O.
  • 474
  • 4
  • 23

2 Answers2

0

Try to install enum34. I found flask_migrate can not detecte changes while i am using enum on Python3-x. Then i saw the comments in this question Defining SQLAlchemy enum column with Python enum raises "ValueError: not a valid enum"

pip install enum34

Note: keep using import enum, import enum34 is wrong.

KC.
  • 2,981
  • 2
  • 12
  • 22
-1

you need to migrate your db definition, e.g. using https://pypi.org/project/alembic/

Milo Bem
  • 1,033
  • 8
  • 20
  • 1
    if you mean running *flask db migrate* then *flask db upgrade*, that I already did. I am using *Flask-Migrate*. – Eric O. Nov 20 '18 at 18:23