5monkeys / django-enumfield

Custom Django field for using enumerations of named constants
MIT License
205 stars 46 forks source link

New stable release #57

Closed ca-simone-chiorazzo closed 4 years ago

ca-simone-chiorazzo commented 4 years ago

We are encountering problems with the fact that the EnumField in version 1.5 dot not allow mandatory field because it set by default based on the default of Enum.

We also noticed that you have already fixed it in the latest beta release.

What's is blocking the new stable release?

Swamii commented 4 years ago

We are about to release 2.0 final. Please note that 2.0 has multiple breaking changes, so it requires multiple changes to your code (as outlined here).

Not sure I follow your issue though. Doesn't EnumField(Enum, default=None) work as a way to require the field to be set?

ca-simone-chiorazzo commented 4 years ago

@Swamii Ok, thanks for the info. We gonna wait for the 2.0 release.

Unfortunately, that workaround does not work because Django tries to insert the record with NULL on the DB but the field does not accept null values and goes in IntegrityError.

Swamii commented 4 years ago

@ca-simone-chiorazzo OK, so there's a different error if default is not provided? I cannot recall.

Either way, we just released 2.0 final. See if it works for you.

ca-simone-chiorazzo commented 4 years ago

@Swamii Yes, the error, when you don't provide the default, is that the EnumField define internally a default using the first value of the Enum and so is impossible make it mandatory.

Swamii commented 4 years ago

@ca-simone-chiorazzo If you want to stay on 1.x then perhaps this works? https://github.com/5monkeys/django-enumfield/issues/25#issuecomment-150467741

Swamii commented 4 years ago

@ca-simone-chiorazzo I'm gonna go ahead and close this, since we have released 2.0 and the conversation died down here. Feel free to reopen if needed.