Git Product home page Git Product logo

Comments (11)

matthewwithanm avatar matthewwithanm commented on July 17, 2024

Which version are you using? 0.5.1 contains #19 which may have fixed this.

from django-enumfields.

bxm156 avatar bxm156 commented on July 17, 2024

Using django-enumfields==0.5.1 and Django==1.7

from django-enumfields.

matthewwithanm avatar matthewwithanm commented on July 17, 2024

Hm, alright. I'll try to look into this later this week. At the moment, the tests aren't running with Django 1.7 because of the app loading changes so that'll probably have to come first.

from django-enumfields.

bxm156 avatar bxm156 commented on July 17, 2024

I believe this will help helpful:
https://code.djangoproject.com/ticket/22951

I updated to 1.7.1 and still have problems, perhaps because the check for 'type' added in Django 1.7.1 fails for django-enumfield's enum class. I will have to investigate more.

from django-enumfields.

gavinwahl avatar gavinwahl commented on July 17, 2024

This is how I solved the issue, including a workaround for 22961:

class DeconstructableEnum(Enum):
    def __init__(self, *args, **kwargs):
        super(DeconstructableEnum, self).__init__(*args, **kwargs)
        # migrations are able to serialize the class natively, but not instances
        self.deconstruct = lambda: ('%s.%s' % (self.__module__, self.__class__.__name__), [self.value], {})

from django-enumfields.

matthewwithanm avatar matthewwithanm commented on July 17, 2024

@gavinwahl Oh, that's clever! Are there any drawbacks to doing that?

from django-enumfields.

gavinwahl avatar gavinwahl commented on July 17, 2024

It's kind of hacky and confusing. Depending on whether a fix is released in Django, we might not need a workaround at all. I opened https://code.djangoproject.com/ticket/23950 for this issue.

If it doesn't end up getting fixed in Django and getting released in 1.7.2, I don't see a drawback to doing this workaround in django-enumfields.

from django-enumfields.

matthewwithanm avatar matthewwithanm commented on July 17, 2024

👍 If you want to submit a PR, I'll merge it.

from django-enumfields.

gavinwahl avatar gavinwahl commented on July 17, 2024

The Django bug was fixed and backported to 1.7.x so we can add a normal deconstruct method without any workaround.

from django-enumfields.

matthewwithanm avatar matthewwithanm commented on July 17, 2024

Oh cool. Does that mean we're good to close this?

from django-enumfields.

akx avatar akx commented on July 17, 2024

Using a bleeding edge Django (with the supposedly fixing commit dee4d23f7e703aec2d1244e4facbf7f4c88deed5 included) did not fix the problem for me. (Same error.)

However, the first commit in the referenced PR (#24) does fix this, by serializing the default kwarg as the enum's underlying value. Comments appreciated :-)

from django-enumfields.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.