Skip to content
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

Labeled flags don't work. #37

Closed
natecox opened this issue Apr 2, 2014 · 3 comments
Closed

Labeled flags don't work. #37

natecox opened this issue Apr 2, 2014 · 3 comments

Comments

@natecox
Copy link

natecox commented Apr 2, 2014

I've attempted to get a set of flags that have labels associated with them, as per the README, but it doesn't seem to actually work.

class MyModel(models.Model):
    flags = BitField(flags=(
        ('awesome_flag', 'Awesome Flag!'),
        ('flaggy_foo', 'Flaggy Foo'),
        ('baz_bar', 'Baz (bar)'),
    ))

If I use that verbatim, I get three string flags that are read as ('awesome_flag', 'Awesome Flag!') rather than as Awesome Flag! with a value of awesome_flag (using the admin view).

Saving via the admin also fails, for lack of appropriate value.

@johnboiles
Copy link

What version of django-bitfield do you have installed?

I ran into this too a month ago. The README on the github.com page was for the development version, but I had 1.6.4 installed, which doesn't have labels.

Looks like 1.7.0 is now on PyPi as of May 10th. Maybe time to do pip install --upgrade django-bitfield

@natecox
Copy link
Author

natecox commented May 30, 2014

@johnboiles
1.7 does seem to have labels, but I have to say they're less than intuitive to use unless I'm just missing something entirely. You can't, for example:

o = MyModel.objects.first()
for f in o.flags:
    print f.label # or f.get_label()

instead you seem to have to

for f in o.flags:
    print o.flags.get_label(f[0])

@johnboiles
Copy link

I don't disagree with you. Between this and issues #35 & #28, I'm considering moving away from django-bitfield. Might not be worth dealing with the nuances of django-bitfield to save a few bytes.

@natecox natecox closed this as completed May 31, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants