-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Django 1.7b4 #11
Comments
|
Does not work: class FooModel(modelsModels):
class Gender(Enum):
MALE = "m"
FEMALE = "f"
UNKNOWN = "u"
class Labels:
MALE = 'Male',
FEMALE = 'Female',
UNKNOWN = 'Unknown'
gender = EnumField(Gender, max_length=1, blank=True, null=True)
|
I see; I hadn't actually tried migrations (just got it to work with unmigrated models). I was able to get it working by adding a deconstruct method in the init method like so: def __init__(self, value):
def deconstruct():
return (
'%s.%s' % (self.__class__.__module__, self.__class__.__name__),
(self.value,),
{}
)
self.deconstruct = deconstruct A standard deconstruct method fails because Django tries to call it on the type, not just the instances. I think this might be considered a Django bug, so I haven't yet made a pull request here. If I've missed something, I'm open to suggestions. I would also remove 'choices' in the deconstruct method in
|
There could occur another issue with nested classes. class FooModel(models.Model):
class Gender(Enum):
MALE = "m"
FEMALE = "f"
UNKNOWN = "u"
g = EnumFIeld(Gender) vs. class Gender(Enum):
MALE = "m"
FEMALE = "f"
UNKNOWN = "u"
class FooModel(models.Model):
g = EnumFIeld(Gender) Something like |
Related Django bug: https://code.djangoproject.com/ticket/22951 |
@bh @samh Sorry this went under the radar ): I just pushed 0.5.1 which removes |
Hi,
could you please add support for Django >= 1.7. I get the following error:
.. when running:
Thank you!
The text was updated successfully, but these errors were encountered: