disqus / django-bitfield Goto Github PK
View Code? Open in Web Editor NEWA BitField extension for Django Models
Home Page: http://code.disqus.com
License: Apache License 2.0
A BitField extension for Django Models
Home Page: http://code.disqus.com
License: Apache License 2.0
The BitField does not seem to support Python 2.5 because the tuple.index() method was not introduced until 2.6. If this is intended, it would be good to add a Python 2.6 requirement to the readme. Otherwise, here's the error message that pops up whenever __ getattr __, __ setattr __, and __ contains __ are used for BitHandler:
Traceback (most recent call last):
File "", line 1, in
File "/.../bitfield/init.py", line 217, in iteritems
yield (k, getattr(self, k).is_set)
File "/.../bitfield/init.py", line 178, in getattr
return self.get_bit(self._keys.index(key))
AttributeError: 'tuple' object has no attribute 'index'
I was able to solve this by turning "self._keys.index(key)" to "list(self._keys).index(key)", but I'm not sure if this is the best approach. I just wanted you to be aware of the tuple.index() issue in case you wanted to support Python 2.5.
it seems like the master branch now supports django version up to 1.10, but the readme file only indicated 1.4, which is misleading.
I'm using Django 1.3.1 with PostgreSQL, setup a very simple example like this :
dubious = BitField(flags=DOUBT_FLAGS, verbose_name=_(u"Dubious categories"))
Whether I use the stock field in Admin forms or regular forms, or I force the form field to be a BitFormField, Django always shows a TextInput. (In the admin, submitting raises an AttributeError in types.py, line 171) I've come to think there might be a bug, or a misuse of the app.
Hi,
I'm having a problem when using BitFieldListFilter
on Django 1.8
Selecting any item in the filter raises the following error:
Traceback:
File "/Users/antonin/Documents/Projects/venv/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/antonin/Documents/Projects/venv/lib/python3.4/site-packages/django/contrib/admin/options.py" in wrapper
616. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/Users/antonin/Documents/Projects/venv/lib/python3.4/site-packages/django/utils/decorators.py" in _wrapped_view
110. response = view_func(request, *args, **kwargs)
File "/Users/antonin/Documents/Projects/venv/lib/python3.4/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)
File "/Users/antonin/Documents/Projects/venv/lib/python3.4/site-packages/django/contrib/admin/sites.py" in inner
233. return view(request, *args, **kwargs)
File "/Users/antonin/Documents/Projects/venv/lib/python3.4/site-packages/django/utils/decorators.py" in _wrapper
34. return bound_func(*args, **kwargs)
File "/Users/antonin/Documents/Projects/venv/lib/python3.4/site-packages/django/utils/decorators.py" in _wrapped_view
110. response = view_func(request, *args, **kwargs)
File "/Users/antonin/Documents/Projects/venv/lib/python3.4/site-packages/django/utils/decorators.py" in bound_func
30. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/Users/antonin/Documents/Projects/venv/lib/python3.4/site-packages/django/contrib/admin/options.py" in changelist_view
1548. self.list_max_show_all, self.list_editable, self)
File "/Users/antonin/Documents/Projects/venv/lib/python3.4/site-packages/django/contrib/admin/views/main.py" in __init__
82. self.get_results(request)
File "/Users/antonin/Documents/Projects/venv/lib/python3.4/site-packages/django/contrib/admin/views/main.py" in get_results
177. result_count = paginator.count
File "/Users/antonin/Documents/Projects/venv/lib/python3.4/site-packages/django/core/paginator.py" in _get_count
77. self._count = len(self.object_list)
File "/Users/antonin/Documents/Projects/venv/lib/python3.4/site-packages/django/db/models/query.py" in __len__
144. self._fetch_all()
File "/Users/antonin/Documents/Projects/venv/lib/python3.4/site-packages/django/db/models/query.py" in _fetch_all
965. self._result_cache = list(self.iterator())
File "/Users/antonin/Documents/Projects/venv/lib/python3.4/site-packages/django/db/models/query.py" in iterator
238. results = compiler.execute_sql()
File "/Users/antonin/Documents/Projects/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py" in execute_sql
829. sql, params = self.as_sql()
File "/Users/antonin/Documents/Projects/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py" in as_sql
387. where, w_params = self.compile(self.query.where)
File "/Users/antonin/Documents/Projects/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py" in compile
357. sql, params = node.as_sql(self, self.connection)
File "/Users/antonin/Documents/Projects/venv/lib/python3.4/site-packages/django/db/models/sql/where.py" in as_sql
104. sql, params = compiler.compile(child)
File "/Users/antonin/Documents/Projects/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py" in compile
357. sql, params = node.as_sql(self, self.connection)
File "/Users/antonin/Documents/Projects/venv/lib/python3.4/site-packages/django/db/models/lookups.py" in as_sql
210. lhs_sql, params = self.process_lhs(compiler, connection)
File "/Users/antonin/Documents/Projects/venv/lib/python3.4/site-packages/bitfield/query.py" in process_lhs
38. params.extend(self.get_db_prep_lookup(self.rhs, connection)[1])
Exception Type: TypeError at /admin/core/item/
Exception Value: 'CombinedExpression' object is not iterable
It looks like this should be fixed for Django 1.8
If key is in unicode, for example to display cyrillic labels, admin panel fails with:
File "bitfield/bitfield/types.py" in iteritems
211. yield (k, getattr(self, k).is_set)
Exception Value: Caught UnicodeEncodeError while rendering: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)
In the Usage section of the README, is this code example:
# Add awesome_flag (does not work in SQLite)
MyModel.objects.filter(pk=o.pk).update(flags=F('flags') | MyModel.flags.awesome_flag)
where F, seemingly some kind of function, is not defined anywhere. This might be a bug, or something that requires clarification.
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.
so I have a model like this which uses bitfield.
class Role(models.Model):
"""
Represents a Global-Role object.
Roles have their own:
- Hex Color Code [Integer Representation]
- Name [&]
- Position
- Permissions.
A null positional value indicates a default role.
As of now, clusters only have a single default role [@everyone].
"""
class Meta:
ordering = ['-position']
unique_together = ('position', 'parent',)
permission_flags = [
('READ_DATA', 'can read cluster data'),
('WRITE_DATA', 'can write to cluster'),
('MANAGE_CLUSTER', 'can manage cluster'),
('MANAGE_FIELD_DATA', "can manage cluster's field data"),
('MANAGE_DATASHEETS', "can manage cluster's datasheets"),
('MANAGE_ROLES', "can manage cluster's roles"),
('MANAGE_FIELDS', "can manage cluster's fields"),
('MANAGE_CONSTRAINTS', "can manage cluster's constraints"),
('KICK_MEMBERS', 'can remove members from the cluster'),
('MANAGE_MEMBERS', 'can modify members present in the cluster')
]
def __str__(self):
return self.name
objects = RolesManager()
id = models.BigAutoField(primary_key=True, db_index=True, editable=False, auto_created=True)
permissions = BitField(flags=permission_flags, db_index=True)
I want to return all the flags of the model in a bitwise format, how can this be done?
Can someone please help me?
In mysql, executing "select 2 | -2;" yields 18446744073709551614 instead of -2. This causes the following test to fail:
https://github.com/disqus/django-bitfield/blob/master/bitfield/tests/tests.py#L169
I'm having a problem using the admin page filter on Django 1.7, which I didn't have before the commit ff2e97f.
When I filter using one of the available flags (URL being http://127.0.0.1:8000/admin/my_app/mymodel/?flags=32
, I have the following error:
Internal Server Error: /admin/my_app/mymodel/
Traceback (most recent call last):
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/core/paginator.py", line 72, in _get_count
self._count = self.object_list.count()
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/db/models/query.py", line 338, in count
return self.query.get_count(using=self.db)
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/db/models/sql/query.py", line 436, in get_count
number = obj.get_aggregation(using=using)[None]
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/contrib/gis/db/models/sql/query.py", line 76, in get_aggregation
return super(GeoQuery, self).get_aggregation(using, force_subq)
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/db/models/sql/query.py", line 402, in get_aggregation
result = query.get_compiler(using).execute_sql(SINGLE)
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 775, in execute_sql
sql, params = self.as_sql()
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 109, in as_sql
where, w_params = self.compile(self.query.where)
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 80, in compile
return node.as_sql(self, self.connection)
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/db/models/sql/where.py", line 106, in as_sql
sql, params = qn.compile(child)
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 80, in compile
return node.as_sql(self, self.connection)
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/db/models/lookups.py", line 149, in as_sql
lhs_sql, params = self.process_lhs(qn, connection)
File "/home/alenfant/project/venv/src/django-bitfield/bitfield/query.py", line 33, in process_lhs
params.extend(self.get_db_prep_lookup(self.rhs, connection)[1])
TypeError: 'SQLEvaluator' object is not iterable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/core/handlers/base.py", line 111, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/contrib/admin/options.py", line 583, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/utils/decorators.py", line 105, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/views/decorators/cache.py", line 52, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/contrib/admin/sites.py", line 206, in inner
return view(request, *args, **kwargs)
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/utils/decorators.py", line 29, in _wrapper
return bound_func(*args, **kwargs)
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/utils/decorators.py", line 105, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/utils/decorators.py", line 25, in bound_func
return func.__get__(self, type(self))(*args2, **kwargs2)
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/contrib/admin/options.py", line 1485, in changelist_view
self.list_max_show_all, self.list_editable, self)
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/contrib/admin/views/main.py", line 110, in __init__
self.get_results(request)
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/contrib/admin/views/main.py", line 219, in get_results
result_count = paginator.count
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/core/paginator.py", line 77, in _get_count
self._count = len(self.object_list)
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/db/models/query.py", line 122, in __len__
self._fetch_all()
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/db/models/query.py", line 966, in _fetch_all
self._result_cache = list(self.iterator())
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/db/models/query.py", line 265, in iterator
for row in compiler.results_iter():
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 700, in results_iter
for rows in self.execute_sql(MULTI):
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 775, in execute_sql
sql, params = self.as_sql()
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 109, in as_sql
where, w_params = self.compile(self.query.where)
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 80, in compile
return node.as_sql(self, self.connection)
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/db/models/sql/where.py", line 106, in as_sql
sql, params = qn.compile(child)
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 80, in compile
return node.as_sql(self, self.connection)
File "/home/alenfant/project/venv/lib/python3.4/site-packages/django/db/models/lookups.py", line 149, in as_sql
lhs_sql, params = self.process_lhs(qn, connection)
File "/home/alenfant/project/venv/src/django-bitfield/bitfield/query.py", line 33, in process_lhs
params.extend(self.get_db_prep_lookup(self.rhs, connection)[1])
TypeError: 'SQLEvaluator' object is not iterable
The current release is over 2 years old and obviously not in sync with the master branch. From what I can gather, the master branch should work with Django 2.x whereas the current PyPI release does not (fully).
The widgets lack the renderer
parameter it seems
Hi There!
Since django2.2 will become soon the new LTS version, I'm wondering if you can provide a new release of django-bitfield compliant with this version. I've seen in commit history since the 3rd september the compliance is guarantee for django >=1.10 (893b5ae), can you please release a new version with those commits ?
I've seen on pypi the last available release has been done the 13th July 2019.
Many thxs!
Model.flags.flag1 & Model.flags.flag2 is always equal zero
I can`t filter by two or more flags
Hi,
I am using django-bitfield 1.9.3 in a Django 1.10.7 app in conjunction with django-filter 1.0.4 (and a lot others). I am porting the code from python 2.7 to python 3.6; actually, for the moment, make it work on both python versions.
Now, we have a BitField and a ChoiceFilter filter, something like:
test = BitField(flags=['a', 'b', 'c'], db_index=True)
and
class BitFlagsFilter(ChoiceFilter):
def __init__(self, *args, **kwargs):
self.flags = kwargs.pop('flags', None)
self.generated_choices = tuple(enumerate(self.flags.keys())) if self.flags else ()
super(BitFlagsFilter, self).__init__(*args, choices=self.generated_choices, **kwargs)
On 2.7 works like a charm, on 3.6 it breaks, from within django filters:
/python3.6/site-packages/django_filters/filterset.py in __init__
186. self.filters = copy.deepcopy(self.base_filters)
...
/python3.6/site-packages/bitfield/models.py in __getattr__
31. if key not in self._flags: ...
Error in formatting: RecursionError: maximum recursion depth exceeded
I know that it breaks from filters, but please take a look at this debuging:
(Pdb) self.flags
['a', 'b', 'c']
(Pdb) type(self.flags)
<class 'bitfield.models.BitFieldFlags'>
(Pdb) from copy import deepcopy
(Pdb) deepcopy(self.flags)
['a', 'b', 'c']
(Pdb) self.flags
['a', 'b', 'c']
(Pdb) type(self.flags)
<class 'bitfield.models.BitFieldFlags'>
(Pdb) from copy import deepcopy
(Pdb) deepcopy(self.flags)
*** RecursionError: maximum recursion depth exceeded
Any thoughts about this? Any help/suggestion will be highly appreciated.
I have a model with BitField like this:
class MyModel(models.Model):
notifications = BitField(flags=('facebook', 'phone', 'gmail'))
Say facebook, gmail are active, then in list view(django-admin) want those flag label comma separated.
Hi,
Let's say I have a field
flags = Bitfield(flags=( 'a', 'b'))
now i want to use this value from a queryset
is there a way to get the value in the queryset by doing something like this
m=model.objects.values('flags__a__is_set')
so that i get a value if the bitfield is set or not
because I found no way to do this anywhere so I want to know if this is supported or not?
I switched one of my positive integer fields to a bitfield, and migration gave me:
Running migrations for activation:
- Migrating forwards to 0014_auto__chg_field_productrelease_binary_subtype.
> activation:0014_auto__chg_field_productrelease_binary_subtype
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 443, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 232, in execute
output = self.handle(*args, **options)
File "C:\Python27\lib\site-packages\south\management\commands\migrate.py", line 108, in handle
ignore_ghosts = ignore_ghosts,
File "C:\Python27\lib\site-packages\south\migration\__init__.py", line 213, in migrate_app
success = migrator.migrate_many(target, workplan, database)
File "C:\Python27\lib\site-packages\south\migration\migrators.py", line 235, in migrate_many
result = migrator.__class__.migrate_many(migrator, target, migrations, database)
File "C:\Python27\lib\site-packages\south\migration\migrators.py", line 310, in migrate_many
result = self.migrate(migration, database)
File "C:\Python27\lib\site-packages\south\migration\migrators.py", line 133, in migrate
result = self.run(migration)
File "C:\Python27\lib\site-packages\south\migration\migrators.py", line 99, in run
south.db.db.current_orm = self.orm(migration)
File "C:\Python27\lib\site-packages\south\migration\migrators.py", line 260, in orm
return migration.orm()
File "C:\Python27\lib\site-packages\south\utils\__init__.py", line 62, in method
value = function(self)
File "C:\Python27\lib\site-packages\south\migration\base.py", line 431, in orm
return FakeORM(self.migration_class(), self.app_label())
File "C:\Python27\lib\site-packages\south\orm.py", line 45, in FakeORM
_orm_cache[args] = _FakeORM(*args)
File "C:\Python27\lib\site-packages\south\orm.py", line 124, in __init__
self.models[name] = self.make_model(app_label, model_name, data)
File "C:\Python27\lib\site-packages\south\orm.py", line 317, in make_model
field = self.eval_in_context(code, app, extra_imports)
File "C:\Python27\lib\site-packages\south\orm.py", line 235, in eval_in_context
return eval(code, globals(), fake_locals)
File "<string>", line 1
SouthFieldClass(default=, max_length=64, db_index=True)
^
SyntaxError: invalid syntax
I discovered this the hard way. It seems that if you get a default value for a BitField and then attempt to use the BitFieldCheckboxSelectMultiple widget in the Add view for the model the Django Forms code breaks because it attempts to iterate through the numeric BitField value as if it were a list.
I have forked the code and will be submitting a PR shortly.
For now, enjoy this traceback:
ERROR: Internal Server Error: /admin/recomed/practitioner/add/
Traceback (most recent call last):
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/core/handlers/base.py", line 140, in get_response
response = response.render()
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/response.py", line 105, in render
self.content = self.rendered_content
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/response.py", line 82, in rendered_content
content = template.render(context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 140, in render
return self._render(context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 134, in _render
return self.nodelist.render(context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 830, in render
bit = self.render_node(node, context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 844, in render_node
return node.render(context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/loader_tags.py", line 124, in render
return compiled_parent._render(context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 134, in _render
return self.nodelist.render(context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 830, in render
bit = self.render_node(node, context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 844, in render_node
return node.render(context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/loader_tags.py", line 124, in render
return compiled_parent._render(context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 134, in _render
return self.nodelist.render(context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 830, in render
bit = self.render_node(node, context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 844, in render_node
return node.render(context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/loader_tags.py", line 63, in render
result = block.nodelist.render(context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 830, in render
bit = self.render_node(node, context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 844, in render_node
return node.render(context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/loader_tags.py", line 63, in render
result = block.nodelist.render(context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 830, in render
bit = self.render_node(node, context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 844, in render_node
return node.render(context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/defaulttags.py", line 196, in render
nodelist.append(node.render(context))
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/loader_tags.py", line 156, in render
return self.render_template(self.template, context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/loader_tags.py", line 138, in render_template
output = template.render(context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 140, in render
return self._render(context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 134, in _render
return self.nodelist.render(context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 830, in render
bit = self.render_node(node, context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 844, in render_node
return node.render(context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/defaulttags.py", line 196, in render
nodelist.append(node.render(context))
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/defaulttags.py", line 196, in render
nodelist.append(node.render(context))
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/defaulttags.py", line 285, in render
return nodelist.render(context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 830, in render
bit = self.render_node(node, context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 844, in render_node
return node.render(context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/defaulttags.py", line 285, in render
return nodelist.render(context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 830, in render
bit = self.render_node(node, context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 844, in render_node
return node.render(context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 887, in render
return _render_value_in_context(output, context)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/template/base.py", line 865, in _render_value_in_context
value = force_text(value)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/utils/encoding.py", line 99, in force_text
s = s.__unicode__()
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/forms/forms.py", line 411, in __str__
return self.as_widget()
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/forms/forms.py", line 458, in as_widget
return widget.render(name, self.value(), attrs=attrs)
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/bitfield/forms.py", line 15, in render
name, value, attrs=attrs, choices=enumerate(choices))
File "/home/adamj/Development/Tools/Python/VirtualEnv/x86_64/recomed-pypy-2.5.0-kubuntu/site-packages/django/forms/widgets.py", line 761, in render
str_values = set([force_text(v) for v in value])
TypeError: 'int' object is not iterable
The issue is that the code in BitFieldCheckboxSelectMultiple.render only checks if value is an instance of BitHandler and does not handle the scenario in which it is an integer.
For some context, my record is defined as so:
reason_for_visit_usage_options = (
('use_own', 'Use Custom Reasons for Visits'),
('use_profession', 'Use Profession-specific Reasons For Visits'),
('use_generic', 'Use Generic Reasons for Visits')
)
default_reason_for_visit_usage = (
reason_for_visit_usage_options[0][0],
reason_for_visit_usage_options[1][0],
reason_for_visit_usage_options[2][0],
)
class Practitioner(models.Model):
reason_for_visit_usage = BitField(flags=reason_for_visit_usage_options, default=default_reason_for_visit_usage, null=False, blank=False)
Django 1.4 appears to have moved or removed LegacyConnection, so it fails to import after upgrading.
Last version on pip is still 1.8.0.
Could you release newer versions on pip please ?
If I do the below filter, using ".values" to retrieve profile related values from multiple tables, the bitfield 'interests' is converted into a normal number.
profiles = Profile.objects.filter(to_profile__from_profile=request.user.id).values('id', 'nickname', 'age', 'location', 'country__name', 'description', 'to_profile__like', 'to_profile__favourite', 'interests', 'photo1', 'photo2', 'photo3')
Once the BitField 'interests' is converted into a normal number, if you try and use it you get the error: 'int' object has no attribute 'flags'. It would be very useful if you could pass a number into the BitField and use the flags option. Without this option BitField cannot be used with .values or .value_lists which are very useful filter options.
I admit this is similar to the issue "#98", but that didn't include ".values" and also didn't suggest a solution of passing the number into BitField.
Getting an error with Django 1.11.21 and the latest PyPI release of this library (1.9.3) -
django.db.utils.ProgrammingError: can't adapt type 'CombinedExpression'
When I try to filter by a flag in admin.
The latest release, 1.6.4, is quite old, a new release would be very welcome.
Exclude tests from package
It will reduce package size more than by a third
Would it be a case here?
I'm following the MyModel example, but I am unable to loop through all the flags as described:
for f in o.flags:
print f
Here is the error message:
Traceback (most recent call last):
File "< console >", line 1, in < module >
TypeError: 'BitHandler' object is not iterable
Also, I'm using Django 1.3
I have a model with BitField like this:
class MyModel(models.Model):
notifications = BitField(flags=('facebook', 'email'))
I would like to filter my model just retrieving the values, but the BitField is unable to return the flag values independently. I have unsuccessfully tried:
MyModel.objects.all().values_list(
'id', 'notifications__facebook', 'notification__email'
)
Is there a way to make it work?
Calling self.used_parameters.iteritems()
will fail in Python 3.
Could be changed into six.iteritems(self.used_parameters)
.
Hi, do you have any plans for a new release of this package on pypi ?
There's been a few useful commits in the last year that we'd be happy to have in an official release instead of having to fetch code from a git branch :)
Thank you!
For some bitfield the following works:
some_bitfield & 123
But this doesn't:
123 & some_bitfield
Admin panel fails with:
bitfield/bitfield/admin.py", line 2, in <module>
from django.contrib.admin import FieldListFilter
ImportError: cannot import name FieldListFilter
Easily visible in CI. I'd love help investigating this.
I ported some code that previously worked in Django 1.6, which now seems to fail in Django 1.7. I have the following code:
class FlagsManager(models.Manager): def get_queryset(self): return super(FlagsManager, self).get_queryset().filter( flags=~self.model.flags.INACTIVE)
In Django 1.7 I get a "'BitQueryLookupWrapper' object is not iterable". Seems like Django is trying to do a
params.extend(rhs_params)
where rhs_params is: bitfield.query.BitQueryLookupWrapper object
Traceback: File "/Users/bryanmarty/.env/mybitfieldapp/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 111. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/Users/bryanmarty/mybitfieldapp/mybitfieldapp/apps/registration/views.py" in register 17. if form.is_valid(): File "/Users/bryanmarty/.env/mybitfieldapp/lib/python2.7/site-packages/django/forms/forms.py" in is_valid 162. return self.is_bound and not bool(self.errors) File "/Users/bryanmarty/.env/mybitfieldapp/lib/python2.7/site-packages/django/forms/forms.py" in errors 154. self.full_clean() File "/Users/bryanmarty/.env/mybitfieldapp/lib/python2.7/site-packages/django/forms/forms.py" in full_clean 353. self._clean_fields() File "/Users/bryanmarty/.env/mybitfieldapp/lib/python2.7/site-packages/django/forms/forms.py" in _clean_fields 371. value = getattr(self, 'clean_%s' % name)() File "/Users/bryanmarty/mybitfieldapp/mybitfieldapp/apps/registration/forms.py" in clean_username 51. User._default_manager.get(username=username) File "/Users/bryanmarty/.env/mybitfieldapp/lib/python2.7/site-packages/django/db/models/manager.py" in manager_method 92. return getattr(self.get_queryset(), name)(*args, **kwargs) File "/Users/bryanmarty/.env/mybitfieldapp/lib/python2.7/site-packages/django/db/models/query.py" in get 351. num = len(clone) File "/Users/bryanmarty/.env/mybitfieldapp/lib/python2.7/site-packages/django/db/models/query.py" in __len__ 122. self._fetch_all() File "/Users/bryanmarty/.env/mybitfieldapp/lib/python2.7/site-packages/django/db/models/query.py" in _fetch_all 966. self._result_cache = list(self.iterator()) File "/Users/bryanmarty/.env/mybitfieldapp/lib/python2.7/site-packages/django/db/models/query.py" in iterator 265. for row in compiler.results_iter(): File "/Users/bryanmarty/.env/mybitfieldapp/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in results_iter 700. for rows in self.execute_sql(MULTI): File "/Users/bryanmarty/.env/mybitfieldapp/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql 775. sql, params = self.as_sql() File "/Users/bryanmarty/.env/mybitfieldapp/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in as_sql 109. where, w_params = self.compile(self.query.where) File "/Users/bryanmarty/.env/mybitfieldapp/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in compile 80. return node.as_sql(self, self.connection) File "/Users/bryanmarty/.env/mybitfieldapp/lib/python2.7/site-packages/django/db/models/sql/where.py" in as_sql 106. sql, params = qn.compile(child) File "/Users/bryanmarty/.env/mybitfieldapp/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in compile 80. return node.as_sql(self, self.connection) File "/Users/bryanmarty/.env/mybitfieldapp/lib/python2.7/site-packages/django/db/models/lookups.py" in as_sql 151. params.extend(rhs_params) Exception Type: TypeError at /register/ Exception Value: 'BitQueryLookupWrapper' object is not iterable
Hi,
I have installed bitfield in my virtualenv using pip (like I do for all the package). The bitfield module is properly installed in the site-package folder. In my dev environement, I can import bitfield without any trouble. When I do the same on my prod server it fails with an ImportError.
The bitfield package is here and properly installed.
I use mod_wsgi with apache and python 2.7.3 on my server. In django.wsgi I reconfigure my python path to point to my virtualenv (and this has been working for two years and I am using many packages)
When I launch the django shell (./manage.py shell) I can import bitfield no problem:
from bitfield import BitField # this work ok.
But when I try to load a page, it will fail with:
Traceback (most recent call last):
File "/home/jedi/sites/django-1.6.2-env/lib/python2.7/site-packages/django/core/handlers/base.py", line 90, in get_response
response = middleware_method(request)
File "/home/jedi/sites/django-1.6.2-env/lib/python2.7/site-packages/lockdown/middleware.py", line 96, in process_request
form = form_class(data=form_data, *_self.form_kwargs)
File "/home/jedi/sites/django-1.6.2-env/lib/python2.7/site-packages/lockdown/forms.py", line 38, in init
super(LockdownForm, self).init(_args, **kwargs)
File "/home/jedi/sites/django-1.6.2-env/lib/python2.7/site-packages/django/forms/forms.py", line 90, in init
self.label_suffix = label_suffix if label_suffix is not None else _(':')
File "/home/jedi/sites/django-1.6.2-env/lib/python2.7/site-packages/django/utils/translation/init.py", line 76, in ugettext
return _trans.ugettext(message)
File "/home/jedi/sites/django-1.6.2-env/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 281, in ugettext
return do_translate(message, 'ugettext')
File "/home/jedi/sites/django-1.6.2-env/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 263, in do_translate
_default = translation(settings.LANGUAGE_CODE)
File "/home/jedi/sites/django-1.6.2-env/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 177, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/home/jedi/sites/django-1.6.2-env/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 159, in _fetch
app = import_module(appname)
File "/home/jedi/sites/django-1.6.2-env/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
import(name)
[... application related stuff anonymized ...]
from bitfield import BitField
ImportError: No module named bitfield
Also tried
from bitfield.models import BitField
But no luck.
Plus, from the command line, this works ok:
python /path/to/my/website/django.wsgi
Note that I can import many other modules with no problem whatsoever... What is specific about django-bitfield??
Again the path is properly set in the .wsgi loader as many other package are being used by the site (including django !).
Any help is appreciated...
Thanks.
I pulled the 1.8 release from pypi and saw two failing tests while using MySQL:
test_negate (bitfield.tests.tests.BitFieldTest)
line 229: self.assertEqual(BitFieldTestModel.objects.filter(flags=~BitFieldTestModel.flags.FLAG_0).count(), 1)
AssertionError: 0 != 1
test_update (bitfield.tests.tests.BitFieldTest)
line 201: self.assertTrue(instance.flags.FLAG_1)
<Bit: number=1, is_set=False> is not true
Are these the only two known issues preventing full mysql support, or are there others that may not be included in test cases? I am actually unsure what specifically the issues are with mysql? Because I rolled my own (much simpler) bitwise code that performs the updating and negating operations via queries on MySQL and it works just fine. I'd love to be able to use bitfield since its a much fuller and more integrated solution than my own. Could someone give me a pointer more directly looking at the issue, and perhaps I can attempt to give a patch?
Thanks
Hi,
Following this commit on Django master (upcoming stable 1.8):
commit f59fd15c4928caf3dfcbd50f6ab47be409a43b01
Author: Josh Smeaton <[email protected]>
Date: Thu Dec 26 00:13:18 2013 +1100
Fixed #14030 -- Allowed annotations to accept all expressions
django.db.models.sql.expressions module has been removed, with the SQLEvaluator along with it. This SQLEvaluator is used by BitField:
[...]
from bitfield import BitField
File "/home/luke/development/django-1.8c1-env/local/lib/python2.7/site-packages/bitfield/__init__.py", line 12, in <module>
from bitfield.models import Bit, BitHandler, CompositeBitField, BitField # noqa
File "/home/luke/development/django-1.8c1-env/local/lib/python2.7/site-packages/bitfield/models.py", line 2, in <module>
from django.db.models.sql.expressions import SQLEvaluator
ImportError: No module named expressions
I have no idea of the amount of work necessary to get rid of SQLEvaluator. Can bitfield maintainer fix this?
q1 = ModelOne.objects.filter(flags=ModelOne.flags.flag)
q2 = ModelTwo.objects.filter(id__in=q1)
The produced sql will be like this,
SELECT "model_one"."id", FROM "model_one" WHERE ("model_one"."id" IN (SELECT U0."id" FROM "model_two" U0 WHERE (U0."flags" = ("model_two"."flags" | 1)))
From the sql, the condition in sub-query is refer to "model_two" not U0.
This will produce invalid reference table in the query.
Not implemented __ne__
method for BitHandler
. For example:
class MyModel(models.Model):
...
flags = BitField(...)
...
obj1 = MyModel.objects.get(pk=1)
obj2 = MyModel.objects.get(pk=1)
# True
compare1 = obj1.flags == obj2.flags
# True againg (wrong)
compare1 = obj1.flags != obj2.flags
# manual checking
compare3 = obj1.flags._value == obj2.flags._value # True
compare4 = obj1.flags._value != obj2.flags._value # False
an index that can handle every flag (bit) filtering, any ideas?
In Django 1.8, SubfieldBase has been deprecated and will be removed in Django 1.10.
I'm using Django 1.9 and getting "RemovedInDjango110Warning".
django-bitfield/bitfield/types.py
Line 121 in 32d5f06
may be need a method to convert key to value, i try many time to find out how to convert
result = BitHandler(0, tuple(TeamPerm.permission))
for label in data:
setattr(result, label, True)
Hi All,
I am trying to build django-bitfield on travis-ci but jobs on python 3.5 & 3.6 are failing. Error encountered during setup. Below are the logs
travis_setup_postgresql
Starting PostgreSQL v9.6
sudo systemctl start [email protected]
git.checkout
0.65s$ git clone --depth=50 --branch=master https://github.com/kishorkunal-raj/django-bitfield.git kishorkunal-raj/django-bitfield
0.01s0.00s$ source ~/virtualenv/python3.5/bin/activate
$ python --version
Python 3.5.6
$ pip --version
pip 18.1 from /home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/pip (python 3.5)
install
1.90s$ pip install flake8 tox-travis
before_script
0.22s$ psql -c 'create database bitfield;' -U postgres;
0.58s$ make lint
--> Linting Python files
PYFLAKES_NODOCTEST=1 flake8 bitfield
The command "make lint" exited with 0.
91.55s$ make test
--> Running Python tests
tox
GLOB sdist-make: /home/travis/build/kishorkunal-raj/django-bitfield/setup.py
py35-django110-sqlite create: /home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite
py35-django110-sqlite installdeps: pytest, psycopg2>=2.3, Django>=1.10,<1.11, pytest-django>=3.1
py35-django110-sqlite inst: /home/travis/build/kishorkunal-raj/django-bitfield/.tox/.tmp/package/1/django-bitfield-2.0.1.zip
py35-django110-sqlite installed: attrs==20.3.0,Django==1.10.8,django-bitfield==2.0.1,importlib-metadata==2.1.1,iniconfig==1.1.1,packaging==20.7,pathlib2==2.3.5,pluggy==0.13.1,psycopg2==2.8.6,py==1.9.0,pyparsing==2.4.7,pytest==6.1.2,pytest-django==4.1.0,six==1.15.0,toml==0.10.2,zipp==1.2.0
py35-django110-sqlite run-test-pre: PYTHONHASHSEED='1251796090'
py35-django110-sqlite run-test: commands[0] | py.test
============================= test session starts ==============================
platform linux -- Python 3.5.6, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
cachedir: .tox/py35-django110-sqlite/.pytest_cache
rootdir: /home/travis/build/kishorkunal-raj/django-bitfield, configfile: setup.cfg
plugins: django-4.1.0
collected 29 items
bitfield/tests/tests.py EEEEEEEEEEEEEEEEEEEEEEEEEEEEE [100%]
==================================== ERRORS ====================================
_______________ ERROR at setup of BitHandlerTest.test_comparison _______________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
________________ ERROR at setup of BitHandlerTest.test_defaults ________________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
________________ ERROR at setup of BitHandlerTest.test_mutation ________________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
____________ ERROR at setup of BitHandlerTest.test_nonzero_default _____________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
______________________ ERROR at setup of BitTest.test_and ______________________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
__________________ ERROR at setup of BitTest.test_comparison ___________________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
______________________ ERROR at setup of BitTest.test_int ______________________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
______________________ ERROR at setup of BitTest.test_or _______________________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
______________________ ERROR at setup of BitTest.test_xor ______________________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
__________________ ERROR at setup of BitFieldTest.test_basic ___________________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
_____________ ERROR at setup of BitFieldTest.test_binary_capacity ______________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
______________ ERROR at setup of BitFieldTest.test_default_value _______________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
__________ ERROR at setup of BitFieldTest.test_defaults_as_key_names ___________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
_____________ ERROR at setup of BitFieldTest.test_dictionary_init ______________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
__________________ ERROR at setup of BitFieldTest.test_negate __________________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
_____________ ERROR at setup of BitFieldTest.test_regression_1425 ______________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
__________________ ERROR at setup of BitFieldTest.test_select __________________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
________ ERROR at setup of BitFieldTest.test_select_complex_expression _________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
__________________ ERROR at setup of BitFieldTest.test_update __________________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
___________ ERROR at setup of BitFieldTest.test_update_with_handler ____________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
_________ ERROR at setup of BitFieldSerializationTest.test_added_field _________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
_ ERROR at setup of BitFieldSerializationTest.test_can_unserialize_bithandler __
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
_____ ERROR at setup of BitFieldSerializationTest.test_pickle_integration ______
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
____________ ERROR at setup of CompositeBitFieldTest.test_get_flag _____________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
_____________ ERROR at setup of CompositeBitFieldTest.test_hasattr _____________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
____________ ERROR at setup of CompositeBitFieldTest.test_set_flag _____________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
_______________ ERROR at setup of BitFormFieldTest.test_form_new _______________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
___________ ERROR at setup of BitFormFieldTest.test_form_new_invalid ___________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
_____________ ERROR at setup of BitFormFieldTest.test_form_update ______________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
=========================== short test summary info ============================
ERROR bitfield/tests/tests.py::BitHandlerTest::test_comparison - TypeError: s...
ERROR bitfield/tests/tests.py::BitHandlerTest::test_defaults - TypeError: set...
ERROR bitfield/tests/tests.py::BitHandlerTest::test_mutation - TypeError: set...
ERROR bitfield/tests/tests.py::BitHandlerTest::test_nonzero_default - TypeErr...
ERROR bitfield/tests/tests.py::BitTest::test_and - TypeError: setup_test_envi...
ERROR bitfield/tests/tests.py::BitTest::test_comparison - TypeError: setup_te...
ERROR bitfield/tests/tests.py::BitTest::test_int - TypeError: setup_test_envi...
ERROR bitfield/tests/tests.py::BitTest::test_or - TypeError: setup_test_envir...
ERROR bitfield/tests/tests.py::BitTest::test_xor - TypeError: setup_test_envi...
ERROR bitfield/tests/tests.py::BitFieldTest::test_basic - TypeError: setup_te...
ERROR bitfield/tests/tests.py::BitFieldTest::test_binary_capacity - TypeError...
ERROR bitfield/tests/tests.py::BitFieldTest::test_default_value - TypeError: ...
ERROR bitfield/tests/tests.py::BitFieldTest::test_defaults_as_key_names - Typ...
ERROR bitfield/tests/tests.py::BitFieldTest::test_dictionary_init - TypeError...
ERROR bitfield/tests/tests.py::BitFieldTest::test_negate - TypeError: setup_t...
ERROR bitfield/tests/tests.py::BitFieldTest::test_regression_1425 - TypeError...
ERROR bitfield/tests/tests.py::BitFieldTest::test_select - TypeError: setup_t...
ERROR bitfield/tests/tests.py::BitFieldTest::test_select_complex_expression
ERROR bitfield/tests/tests.py::BitFieldTest::test_update - TypeError: setup_t...
ERROR bitfield/tests/tests.py::BitFieldTest::test_update_with_handler - TypeE...
ERROR bitfield/tests/tests.py::BitFieldSerializationTest::test_added_field - ...
ERROR bitfield/tests/tests.py::BitFieldSerializationTest::test_can_unserialize_bithandler
ERROR bitfield/tests/tests.py::BitFieldSerializationTest::test_pickle_integration
ERROR bitfield/tests/tests.py::CompositeBitFieldTest::test_get_flag - TypeErr...
ERROR bitfield/tests/tests.py::CompositeBitFieldTest::test_hasattr - TypeErro...
ERROR bitfield/tests/tests.py::CompositeBitFieldTest::test_set_flag - TypeErr...
ERROR bitfield/tests/tests.py::BitFormFieldTest::test_form_new - TypeError: s...
ERROR bitfield/tests/tests.py::BitFormFieldTest::test_form_new_invalid - Type...
ERROR bitfield/tests/tests.py::BitFormFieldTest::test_form_update - TypeError...
============================== 29 errors in 0.18s ==============================
ERROR: InvocationError for command /home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-sqlite/bin/py.test (exited with code 1)
py35-django110-postgres create: /home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres
py35-django110-postgres installdeps: pytest, psycopg2>=2.3, Django>=1.10,<1.11, pytest-django>=3.1
py35-django110-postgres inst: /home/travis/build/kishorkunal-raj/django-bitfield/.tox/.tmp/package/1/django-bitfield-2.0.1.zip
py35-django110-postgres installed: attrs==20.3.0,Django==1.10.8,django-bitfield==2.0.1,importlib-metadata==2.1.1,iniconfig==1.1.1,packaging==20.7,pathlib2==2.3.5,pluggy==0.13.1,psycopg2==2.8.6,py==1.9.0,pyparsing==2.4.7,pytest==6.1.2,pytest-django==4.1.0,six==1.15.0,toml==0.10.2,zipp==1.2.0
py35-django110-postgres run-test-pre: PYTHONHASHSEED='1251796090'
py35-django110-postgres run-test: commands[0] | py.test
============================= test session starts ==============================
platform linux -- Python 3.5.6, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
cachedir: .tox/py35-django110-postgres/.pytest_cache
rootdir: /home/travis/build/kishorkunal-raj/django-bitfield, configfile: setup.cfg
plugins: django-4.1.0
collected 29 items
bitfield/tests/tests.py EEEEEEEEEEEEEEEEEEEEEEEEEEEEE [100%]
==================================== ERRORS ====================================
_______________ ERROR at setup of BitHandlerTest.test_comparison _______________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
________________ ERROR at setup of BitHandlerTest.test_defaults ________________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
________________ ERROR at setup of BitHandlerTest.test_mutation ________________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
____________ ERROR at setup of BitHandlerTest.test_nonzero_default _____________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
______________________ ERROR at setup of BitTest.test_and ______________________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
__________________ ERROR at setup of BitTest.test_comparison ___________________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
______________________ ERROR at setup of BitTest.test_int ______________________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
______________________ ERROR at setup of BitTest.test_or _______________________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
______________________ ERROR at setup of BitTest.test_xor ______________________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
__________________ ERROR at setup of BitFieldTest.test_basic ___________________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
_____________ ERROR at setup of BitFieldTest.test_binary_capacity ______________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
______________ ERROR at setup of BitFieldTest.test_default_value _______________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
__________ ERROR at setup of BitFieldTest.test_defaults_as_key_names ___________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
_____________ ERROR at setup of BitFieldTest.test_dictionary_init ______________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
__________________ ERROR at setup of BitFieldTest.test_negate __________________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
_____________ ERROR at setup of BitFieldTest.test_regression_1425 ______________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
__________________ ERROR at setup of BitFieldTest.test_select __________________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
________ ERROR at setup of BitFieldTest.test_select_complex_expression _________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
__________________ ERROR at setup of BitFieldTest.test_update __________________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
___________ ERROR at setup of BitFieldTest.test_update_with_handler ____________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
_________ ERROR at setup of BitFieldSerializationTest.test_added_field _________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
_ ERROR at setup of BitFieldSerializationTest.test_can_unserialize_bithandler __
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
_____ ERROR at setup of BitFieldSerializationTest.test_pickle_integration ______
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
____________ ERROR at setup of CompositeBitFieldTest.test_get_flag _____________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
_____________ ERROR at setup of CompositeBitFieldTest.test_hasattr _____________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
____________ ERROR at setup of CompositeBitFieldTest.test_set_flag _____________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
_______________ ERROR at setup of BitFormFieldTest.test_form_new _______________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
___________ ERROR at setup of BitFormFieldTest.test_form_new_invalid ___________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
_____________ ERROR at setup of BitFormFieldTest.test_form_update ______________
Traceback (most recent call last):
File "/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/lib/python3.5/site-packages/pytest_django/plugin.py", line 397, in django_test_environment
setup_test_environment(debug=debug)
TypeError: setup_test_environment() got an unexpected keyword argument 'debug'
=========================== short test summary info ============================
ERROR bitfield/tests/tests.py::BitHandlerTest::test_comparison - TypeError: s...
ERROR bitfield/tests/tests.py::BitHandlerTest::test_defaults - TypeError: set...
ERROR bitfield/tests/tests.py::BitHandlerTest::test_mutation - TypeError: set...
ERROR bitfield/tests/tests.py::BitHandlerTest::test_nonzero_default - TypeErr...
ERROR bitfield/tests/tests.py::BitTest::test_and - TypeError: setup_test_envi...
ERROR bitfield/tests/tests.py::BitTest::test_comparison - TypeError: setup_te...
ERROR bitfield/tests/tests.py::BitTest::test_int - TypeError: setup_test_envi...
ERROR bitfield/tests/tests.py::BitTest::test_or - TypeError: setup_test_envir...
ERROR bitfield/tests/tests.py::BitTest::test_xor - TypeError: setup_test_envi...
ERROR bitfield/tests/tests.py::BitFieldTest::test_basic - TypeError: setup_te...
ERROR bitfield/tests/tests.py::BitFieldTest::test_binary_capacity - TypeError...
ERROR bitfield/tests/tests.py::BitFieldTest::test_default_value - TypeError: ...
ERROR bitfield/tests/tests.py::BitFieldTest::test_defaults_as_key_names - Typ...
ERROR bitfield/tests/tests.py::BitFieldTest::test_dictionary_init - TypeError...
ERROR bitfield/tests/tests.py::BitFieldTest::test_negate - TypeError: setup_t...
ERROR bitfield/tests/tests.py::BitFieldTest::test_regression_1425 - TypeError...
ERROR bitfield/tests/tests.py::BitFieldTest::test_select - TypeError: setup_t...
ERROR bitfield/tests/tests.py::BitFieldTest::test_select_complex_expression
ERROR bitfield/tests/tests.py::BitFieldTest::test_update - TypeError: setup_t...
ERROR bitfield/tests/tests.py::BitFieldTest::test_update_with_handler - TypeE...
ERROR bitfield/tests/tests.py::BitFieldSerializationTest::test_added_field - ...
ERROR bitfield/tests/tests.py::BitFieldSerializationTest::test_can_unserialize_bithandler
ERROR bitfield/tests/tests.py::BitFieldSerializationTest::test_pickle_integration
ERROR bitfield/tests/tests.py::CompositeBitFieldTest::test_get_flag - TypeErr...
ERROR bitfield/tests/tests.py::CompositeBitFieldTest::test_hasattr - TypeErro...
ERROR bitfield/tests/tests.py::CompositeBitFieldTest::test_set_flag - TypeErr...
ERROR bitfield/tests/tests.py::BitFormFieldTest::test_form_new - TypeError: s...
ERROR bitfield/tests/tests.py::BitFormFieldTest::test_form_new_invalid - Type...
ERROR bitfield/tests/tests.py::BitFormFieldTest::test_form_update - TypeError...
============================== 29 errors in 0.17s ==============================
ERROR: InvocationError for command /home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django110-postgres/bin/py.test (exited with code 1)
py35-django111-sqlite create: /home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django111-sqlite
py35-django111-sqlite installdeps: pytest, psycopg2>=2.3, Django>=1.11,<1.12, pytest-django>=3.1
py35-django111-sqlite inst: /home/travis/build/kishorkunal-raj/django-bitfield/.tox/.tmp/package/1/django-bitfield-2.0.1.zip
py35-django111-sqlite installed: attrs==20.3.0,Django==1.11.29,django-bitfield==2.0.1,importlib-metadata==2.1.1,iniconfig==1.1.1,packaging==20.7,pathlib2==2.3.5,pluggy==0.13.1,psycopg2==2.8.6,py==1.9.0,pyparsing==2.4.7,pytest==6.1.2,pytest-django==4.1.0,pytz==2020.4,six==1.15.0,toml==0.10.2,zipp==1.2.0
py35-django111-sqlite run-test-pre: PYTHONHASHSEED='1251796090'
py35-django111-sqlite run-test: commands[0] | py.test
============================= test session starts ==============================
platform linux -- Python 3.5.6, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
cachedir: .tox/py35-django111-sqlite/.pytest_cache
rootdir: /home/travis/build/kishorkunal-raj/django-bitfield, configfile: setup.cfg
plugins: django-4.1.0
collected 29 items
bitfield/tests/tests.py ............................. [100%]
============================== 29 passed in 0.21s ==============================
py35-django111-postgres create: /home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django111-postgres
py35-django111-postgres installdeps: pytest, psycopg2>=2.3, Django>=1.11,<1.12, pytest-django>=3.1
py35-django111-postgres inst: /home/travis/build/kishorkunal-raj/django-bitfield/.tox/.tmp/package/1/django-bitfield-2.0.1.zip
py35-django111-postgres installed: attrs==20.3.0,Django==1.11.29,django-bitfield==2.0.1,importlib-metadata==2.1.1,iniconfig==1.1.1,packaging==20.7,pathlib2==2.3.5,pluggy==0.13.1,psycopg2==2.8.6,py==1.9.0,pyparsing==2.4.7,pytest==6.1.2,pytest-django==4.1.0,pytz==2020.4,six==1.15.0,toml==0.10.2,zipp==1.2.0
py35-django111-postgres run-test-pre: PYTHONHASHSEED='1251796090'
py35-django111-postgres run-test: commands[0] | py.test
============================= test session starts ==============================
platform linux -- Python 3.5.6, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
cachedir: .tox/py35-django111-postgres/.pytest_cache
rootdir: /home/travis/build/kishorkunal-raj/django-bitfield, configfile: setup.cfg
plugins: django-4.1.0
collected 29 items
bitfield/tests/tests.py ............................. [100%]
============================== 29 passed in 0.48s ==============================
py35-django20-sqlite create: /home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django20-sqlite
py35-django20-sqlite installdeps: pytest, psycopg2>=2.3, Django>=2.0,<2.1, pytest-django>=3.1
py35-django20-sqlite inst: /home/travis/build/kishorkunal-raj/django-bitfield/.tox/.tmp/package/1/django-bitfield-2.0.1.zip
py35-django20-sqlite installed: attrs==20.3.0,Django==2.0.13,django-bitfield==2.0.1,importlib-metadata==2.1.1,iniconfig==1.1.1,packaging==20.7,pathlib2==2.3.5,pluggy==0.13.1,psycopg2==2.8.6,py==1.9.0,pyparsing==2.4.7,pytest==6.1.2,pytest-django==4.1.0,pytz==2020.4,six==1.15.0,toml==0.10.2,zipp==1.2.0
py35-django20-sqlite run-test-pre: PYTHONHASHSEED='1251796090'
py35-django20-sqlite run-test: commands[0] | py.test
============================= test session starts ==============================
platform linux -- Python 3.5.6, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
cachedir: .tox/py35-django20-sqlite/.pytest_cache
rootdir: /home/travis/build/kishorkunal-raj/django-bitfield, configfile: setup.cfg
plugins: django-4.1.0
collected 29 items
bitfield/tests/tests.py ............................. [100%]
=============================== warnings summary ===============================
.tox/py35-django20-sqlite/lib/python3.5/distutils/init.py:1
/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django20-sqlite/lib/python3.5/distutils/init.py:1: PendingDeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
-- Docs: https://docs.pytest.org/en/stable/warnings.html
======================== 29 passed, 1 warning in 0.20s =========================
py35-django20-postgres create: /home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django20-postgres
py35-django20-postgres installdeps: pytest, psycopg2>=2.3, Django>=2.0,<2.1, pytest-django>=3.1
py35-django20-postgres inst: /home/travis/build/kishorkunal-raj/django-bitfield/.tox/.tmp/package/1/django-bitfield-2.0.1.zip
py35-django20-postgres installed: attrs==20.3.0,Django==2.0.13,django-bitfield==2.0.1,importlib-metadata==2.1.1,iniconfig==1.1.1,packaging==20.7,pathlib2==2.3.5,pluggy==0.13.1,psycopg2==2.8.6,py==1.9.0,pyparsing==2.4.7,pytest==6.1.2,pytest-django==4.1.0,pytz==2020.4,six==1.15.0,toml==0.10.2,zipp==1.2.0
py35-django20-postgres run-test-pre: PYTHONHASHSEED='1251796090'
py35-django20-postgres run-test: commands[0] | py.test
============================= test session starts ==============================
platform linux -- Python 3.5.6, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
cachedir: .tox/py35-django20-postgres/.pytest_cache
rootdir: /home/travis/build/kishorkunal-raj/django-bitfield, configfile: setup.cfg
plugins: django-4.1.0
collected 29 items
bitfield/tests/tests.py ............................. [100%]
=============================== warnings summary ===============================
.tox/py35-django20-postgres/lib/python3.5/distutils/init.py:1
/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django20-postgres/lib/python3.5/distutils/init.py:1: PendingDeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
-- Docs: https://docs.pytest.org/en/stable/warnings.html
======================== 29 passed, 1 warning in 0.47s =========================
py35-django21-sqlite create: /home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django21-sqlite
py35-django21-sqlite installdeps: pytest, psycopg2>=2.3, Django>=2.1,<2.2, pytest-django>=3.1
py35-django21-sqlite inst: /home/travis/build/kishorkunal-raj/django-bitfield/.tox/.tmp/package/1/django-bitfield-2.0.1.zip
py35-django21-sqlite installed: attrs==20.3.0,Django==2.1.15,django-bitfield==2.0.1,importlib-metadata==2.1.1,iniconfig==1.1.1,packaging==20.7,pathlib2==2.3.5,pluggy==0.13.1,psycopg2==2.8.6,py==1.9.0,pyparsing==2.4.7,pytest==6.1.2,pytest-django==4.1.0,pytz==2020.4,six==1.15.0,toml==0.10.2,zipp==1.2.0
py35-django21-sqlite run-test-pre: PYTHONHASHSEED='1251796090'
py35-django21-sqlite run-test: commands[0] | py.test
============================= test session starts ==============================
platform linux -- Python 3.5.6, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
cachedir: .tox/py35-django21-sqlite/.pytest_cache
rootdir: /home/travis/build/kishorkunal-raj/django-bitfield, configfile: setup.cfg
plugins: django-4.1.0
collected 29 items
bitfield/tests/tests.py ............................. [100%]
=============================== warnings summary ===============================
.tox/py35-django21-sqlite/lib/python3.5/distutils/init.py:1
/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django21-sqlite/lib/python3.5/distutils/init.py:1: PendingDeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
-- Docs: https://docs.pytest.org/en/stable/warnings.html
======================== 29 passed, 1 warning in 0.20s =========================
py35-django21-postgres create: /home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django21-postgres
py35-django21-postgres installdeps: pytest, psycopg2>=2.3, Django>=2.1,<2.2, pytest-django>=3.1
py35-django21-postgres inst: /home/travis/build/kishorkunal-raj/django-bitfield/.tox/.tmp/package/1/django-bitfield-2.0.1.zip
py35-django21-postgres installed: attrs==20.3.0,Django==2.1.15,django-bitfield==2.0.1,importlib-metadata==2.1.1,iniconfig==1.1.1,packaging==20.7,pathlib2==2.3.5,pluggy==0.13.1,psycopg2==2.8.6,py==1.9.0,pyparsing==2.4.7,pytest==6.1.2,pytest-django==4.1.0,pytz==2020.4,six==1.15.0,toml==0.10.2,zipp==1.2.0
py35-django21-postgres run-test-pre: PYTHONHASHSEED='1251796090'
py35-django21-postgres run-test: commands[0] | py.test
============================= test session starts ==============================
platform linux -- Python 3.5.6, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
cachedir: .tox/py35-django21-postgres/.pytest_cache
rootdir: /home/travis/build/kishorkunal-raj/django-bitfield, configfile: setup.cfg
plugins: django-4.1.0
collected 29 items
bitfield/tests/tests.py ............................. [100%]
=============================== warnings summary ===============================
.tox/py35-django21-postgres/lib/python3.5/distutils/init.py:1
/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django21-postgres/lib/python3.5/distutils/init.py:1: PendingDeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
-- Docs: https://docs.pytest.org/en/stable/warnings.html
======================== 29 passed, 1 warning in 0.47s =========================
py35-django22-sqlite create: /home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django22-sqlite
py35-django22-sqlite installdeps: pytest, psycopg2>=2.3, Django>=2.2,<2.3, pytest-django>=3.1
py35-django22-sqlite inst: /home/travis/build/kishorkunal-raj/django-bitfield/.tox/.tmp/package/1/django-bitfield-2.0.1.zip
py35-django22-sqlite installed: attrs==20.3.0,Django==2.2.17,django-bitfield==2.0.1,importlib-metadata==2.1.1,iniconfig==1.1.1,packaging==20.7,pathlib2==2.3.5,pluggy==0.13.1,psycopg2==2.8.6,py==1.9.0,pyparsing==2.4.7,pytest==6.1.2,pytest-django==4.1.0,pytz==2020.4,six==1.15.0,sqlparse==0.4.1,toml==0.10.2,zipp==1.2.0
py35-django22-sqlite run-test-pre: PYTHONHASHSEED='1251796090'
py35-django22-sqlite run-test: commands[0] | py.test
============================= test session starts ==============================
platform linux -- Python 3.5.6, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
cachedir: .tox/py35-django22-sqlite/.pytest_cache
rootdir: /home/travis/build/kishorkunal-raj/django-bitfield, configfile: setup.cfg
plugins: django-4.1.0
collected 29 items
bitfield/tests/tests.py ............................. [100%]
=============================== warnings summary ===============================
.tox/py35-django22-sqlite/lib/python3.5/distutils/init.py:1
/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django22-sqlite/lib/python3.5/distutils/init.py:1: PendingDeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
-- Docs: https://docs.pytest.org/en/stable/warnings.html
======================== 29 passed, 1 warning in 0.20s =========================
py35-django22-postgres create: /home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django22-postgres
py35-django22-postgres installdeps: pytest, psycopg2>=2.3, Django>=2.2,<2.3, pytest-django>=3.1
py35-django22-postgres inst: /home/travis/build/kishorkunal-raj/django-bitfield/.tox/.tmp/package/1/django-bitfield-2.0.1.zip
py35-django22-postgres installed: attrs==20.3.0,Django==2.2.17,django-bitfield==2.0.1,importlib-metadata==2.1.1,iniconfig==1.1.1,packaging==20.7,pathlib2==2.3.5,pluggy==0.13.1,psycopg2==2.8.6,py==1.9.0,pyparsing==2.4.7,pytest==6.1.2,pytest-django==4.1.0,pytz==2020.4,six==1.15.0,sqlparse==0.4.1,toml==0.10.2,zipp==1.2.0
py35-django22-postgres run-test-pre: PYTHONHASHSEED='1251796090'
py35-django22-postgres run-test: commands[0] | py.test
============================= test session starts ==============================
platform linux -- Python 3.5.6, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
cachedir: .tox/py35-django22-postgres/.pytest_cache
rootdir: /home/travis/build/kishorkunal-raj/django-bitfield, configfile: setup.cfg
plugins: django-4.1.0
collected 29 items
bitfield/tests/tests.py ............................. [100%]
=============================== warnings summary ===============================
.tox/py35-django22-postgres/lib/python3.5/distutils/init.py:1
/home/travis/build/kishorkunal-raj/django-bitfield/.tox/py35-django22-postgres/lib/python3.5/distutils/init.py:1: PendingDeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
-- Docs: https://docs.pytest.org/en/stable/warnings.html
======================== 29 passed, 1 warning in 0.46s =========================
___________________________________ summary ____________________________________
ERROR: py35-django110-sqlite: commands failed
ERROR: py35-django110-postgres: commands failed
py35-django111-sqlite: commands succeeded
py35-django111-postgres: commands succeeded
py35-django20-sqlite: commands succeeded
py35-django20-postgres: commands succeeded
py35-django21-sqlite: commands succeeded
py35-django21-postgres: commands succeeded
py35-django22-sqlite: commands succeeded
py35-django22-postgres: commands succeeded
Makefile:8: recipe for target 'test' failed
make: *** [test] Error 1
traviThe command "make test" exited with 2.
Done. Your build exited with 1.
Please help me to fix the issue
As the title says the form is always marked and changed.
in the changed_data
property of the Form, initial_value is an int while the data_value is a list
this is causing Field.has_changed
to return True because of the ValidationError
thrown by the to_python
method
Via Alex Gaynor:
MyModel.objects.filter(pk=o.pk).update(flags=MyModel.flags.awesome_flag & MyModel.flags.other_flag)
I have a test case: taylorhughes@0ed47fc
That causes the following error:
LOG: statement: SELECT "tests_compositebitfieldtestmodel"."id", "tests_compositebitfieldtestmodel"."flags_1", "tests_compositebitfieldtestmodel"."flags_2" FROM "tests_compositebitfieldtestmodel" WHERE "tests_compositebitfieldtestmodel"."id" IN (SELECT U0."id" FROM "tests_bitfieldtestmodel" U0 WHERE NOT (U0."another_name" = ("tests_bitfieldtestmodel"."another_name" | 2)))
ERROR: invalid reference to FROM-clause entry for table "tests_bitfieldtestmodel" at character 312
The issue is that the WHERE condition should be updated with a new aliased table name, "U0" in this case. This has something to do with the django field method relabel_aliases()
, I think, but I can't track it down exactly.
If someone can explain how to fix it I'm happy to build and test a fix, but I'm not too familiar with the depths of django here. :)
As per https://docs.djangoproject.com/en/2.0/releases/2.0/#id1:
The django.db.backends.postgresql_psycopg2 module is deprecated in favor of django.db.backends.postgresql. Itβs been an alias since Django 1.9. This only affects code that imports from the module directly. The DATABASES setting can still use 'django.db.backends.postgresql_psycopg2', though you can simplify that by using the 'django.db.backends.postgresql' name added in Django 1.9.
The alias must have been removed in Django 3.0 release.
Removing the '_psycopg2' from the call in types.py lets a project build again.
I have added 'bitfield' to INSTALLED_APPS and added a bitfield named 'features' to my 'Package' model (with about a dozen possible flags).
Loading the Package model in the Django admin throws a TypeError exception with the detail "formfield() takes exactly 1 non-keyword argument (2 given)"
It's happening on line 251 of init.py:
return super(BitField, self).formfield(form_class, **kwargs)
The Django error page shares the following local variables at that point int iem:
Variable | Value |
---|---|
form_class | class 'bitfield.BitFormField' |
kwargs | {'widget': class 'django.contrib.admin.widgets.AdminIntegerFieldWidget'} |
self | bitfield.BitField object at 0xa4c526c |
Also, trying to access the field from the interactive shell throws an AttributeError:
>>> from registry.models import Package
>>> p = Package.objects.get(id=1)
>>> p.features
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/var/python-envs/whispergifts/lib/python2.5/site-packages/bitfield/__init__.py", line 72, in __repr__
return '<%s: %s>' % (self.__class__.__name__, ', '.join('%s=%s' % (k, self.get_bit(n).value) for n, k in enumerate(self._keys)),)
File "/var/python-envs/whispergifts/lib/python2.5/site-packages/bitfield/__init__.py", line 72, in <genexpr>
return '<%s: %s>' % (self.__class__.__name__, ', '.join('%s=%s' % (k, self.get_bit(n).value) for n, k in enumerate(self._keys)),)
AttributeError: 'Bit' object has no attribute 'value'
Have I missed something obvious here?
Exception Type: TypeError at /admin/article/sarticle/add/
Exception Value: 'int' object is not iterable
local vars:
name
'genre_flags'
self
<bitfield.forms.BitFieldCheckboxSelectMultiple object at 0xb40832ac>
attrs
{'id': u'id_genre_flags'}
value
0
choices
()
model:
genre_flags = BitField(flags=[
'PressRelease',
'Satire',
'Blog',
'OpEd',
'Opinion',
'UserGenerated',
], default=('PressRelease',), help_text=genres_help)
admin.py:
formfield_overrides = {
BitField: {'widget': BitFieldCheckboxSelectMultiple},
}
When editing the widget works as expected.
The exception occurs only when adding a new object.
fix follows
BitFieldListFilter seems to filter based on "exact", as opposed to a bitwise operation. So when you select the third item (mask=4), you essentially get this:
queryset.filter(flags=4)
Which will not return the desired result. The queryset() method should be overridden in order to perform the correct bitwise operation when filtering.
Hello!
I have the following env:
Python 3.4.1
Django==1.7c1
django-bitfield==1.7.0
django-nose==1.2
nose==1.3.3
psycopg2==2.5.3
six==1.7.3
When I try to run 'python runtests.py' I get an error:
....
....
File "/home/hellpain/.virtualenvs/nedviga/lib/python3.4/site-packages/django/apps/registry.py", line 119, in check_ready
raise AppRegistryNotReady()
django.core.exceptions.AppRegistryNotReady
In django 1.7 app loading module was refactored, so django-bitfield makes smth wrong.
I had to run tests because in my env I cant save model with bit-fields in django admin, I wanted to find an error, but even couldn
t run tests=))
Thank you for your attention.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.