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

Convert initial value that comes as int to a list of flag names. #32

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

zaxl
Copy link

@zaxl zaxl commented Jun 10, 2013

When editing an object the widget works as expected.
Exception occurs when adding a new object.

When editing an object the widget works as expected.
The exception occurs only when adding a new object.
@zaxl zaxl mentioned this pull request Jun 10, 2013
@@ -25,6 +25,13 @@ def _has_changed(self, initial, data):

class BitFormField(IntegerField):
def __init__(self, choices=(), widget=BitFieldCheckboxSelectMultiple, *args, **kwargs):
if isinstance(kwargs['initial'],int):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a space after the comma

also initial isnt guaranteed to be in kwargs

@dcramer
Copy link
Collaborator

dcramer commented Jun 10, 2013

My feedback is all stylistic though I think the approach may not be very correct. This is making the assumption that there's a 64 bit integer.

@zaxl
Copy link
Author

zaxl commented Jun 10, 2013

Thanks for the feedback!.
I'm not a python expert but

isl = 1 << 63
type (isl) == int
False
type (isl) == long
True

The shift operation is promoted to long when int is 32 bits.
BigIntegerField which is the base field is also guaranteed to be 64 bits.

@SeanHayes
Copy link
Contributor

This can be cancelled once #63 is merged.

Refs #58

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

Successfully merging this pull request may close these issues.

3 participants