{ "info": { "author": "DISQUS", "author_email": "opensource@disqus.com", "bugtrack_url": null, "classifiers": [ "Framework :: Django", "Intended Audience :: Developers", "Intended Audience :: System Administrators", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Software Development" ], "description": "django-bitfield\n---------------\n\n.. image:: https://api.travis-ci.org/disqus/django-bitfield.png?branch=master\n :target: https://travis-ci.org/disqus/django-bitfield\n\nProvides a BitField like class (using a BigIntegerField) for your Django models.\n\n(If you're upgrading from a version before 1.2 the API has changed greatly and is backwards incompatible!)\n\nRequirements\n============\n\n* Django >= 1.10\n* PostgreSQL (see notes)\n\n**Notes:**\n\n- SQLite does not support save operations using a ``Bit`` (per the example under Usage).\n- MySQL fails on most queries related to BitField's.\n\nInstallation\n============\n\nInstall it with pip (or easy_install)::\n\n\tpip install django-bitfield\n\nUsage\n=====\n\nFirst you'll need to attach a BitField to your class. This acts as a BigIntegerField (BIGINT) in your database::\n\n\tfrom bitfield import BitField\n\n\tclass MyModel(models.Model):\n\t flags = BitField(flags=(\n\t 'awesome_flag',\n\t 'flaggy_foo',\n\t 'baz_bar',\n\t ))\n\nFlags can also be defined with labels::\n\n\tclass MyModel(models.Model):\n\t flags = BitField(flags=(\n\t ('awesome_flag', 'Awesome Flag!'),\n\t ('flaggy_foo', 'Flaggy Foo'),\n\t ('baz_bar', 'Baz (bar)'),\n\t ))\n\nNow you can use the field using very familiar Django operations::\n\n\t# Create the model\n\to = MyModel.objects.create(flags=0)\n\n\t# Add awesome_flag (does not work in SQLite)\n\tMyModel.objects.filter(pk=o.pk).update(flags=F('flags').bitor(MyModel.flags.awesome_flag))\n\n\t# Set flags manually to [awesome_flag, flaggy_foo]\n\tMyModel.objects.filter(pk=o.pk).update(flags=MyModel.flags.awesome_flag | MyModel.flags.flaggy_foo)\n\n\t# Remove awesome_flag (does not work in SQLite)\n\tMyModel.objects.filter(pk=o.pk).update(flags=F('flags').bitand(~MyModel.flags.awesome_flag))\n\n\t# Find by awesome_flag\n\tMyModel.objects.filter(flags=MyModel.flags.awesome_flag)\n\n\t# Exclude by awesome_flag\n\tMyModel.objects.filter(flags=~MyModel.flags.awesome_flag)\n\n\t# Test awesome_flag\n\tif o.flags.awesome_flag:\n\t print \"Happy times!\"\n\n\t# List all flags on the field\n\tfor f in o.flags:\n\t print f\n\n\t# Get a flag label\n\tprint o.flags.get_label('awesome_flag')\n\nEnjoy!\n\nAdmin\n=====\n\nTo use the widget in the admin, you'll need to update your ModelAdmin. Add the\nfollowing lines to your ModelAdmin::\n\n\tformfield_overrides = {\n\t\tBitField: {'widget': BitFieldCheckboxSelectMultiple},\n\t}\n\nMake sure you've imported the classes by adding these lines to the top of the file::\n\n\tfrom bitfield import BitField\n\tfrom bitfield.forms import BitFieldCheckboxSelectMultiple\n\nThere is also a ``BitFieldListFilter`` list filter (Django 1.4 or newer).\nTo use it set ``list_filter`` ModelAdmin option::\n\n list_filter = (\n ('flags', BitFieldListFilter,)\n )\n\nBitFieldListFilter is in ``bitfield.admin`` module::\n\n from bitfield.admin import BitFieldListFilter\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/disqus/django-bitfield", "keywords": "", "license": "Apache License", "maintainer": "", "maintainer_email": "", "name": "django-gravy-bitfield", "package_url": "https://pypi.org/project/django-gravy-bitfield/", "platform": "", "project_url": "https://pypi.org/project/django-gravy-bitfield/", "project_urls": { "Homepage": "https://github.com/disqus/django-bitfield" }, "release_url": "https://pypi.org/project/django-gravy-bitfield/1.9.1/", "requires_dist": null, "requires_python": "", "summary": "BitField in Django", "version": "1.9.1" }, "last_serial": 2479944, "releases": { "1.9.1": [ { "comment_text": "", "digests": { "md5": "3dad288f6639acdb15ba037a7b854ca5", "sha256": "0c0eec665c680e73a5b056dddde62a2de95aebaa71d88f23f45962b593585a30" }, "downloads": -1, "filename": "django-gravy-bitfield-1.9.1.tar.gz", "has_sig": false, "md5_digest": "3dad288f6639acdb15ba037a7b854ca5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16016, "upload_time": "2016-11-24T00:05:08", "url": "https://files.pythonhosted.org/packages/70/21/ed3ffca6bb257116b621db71870c538adf9e08d48d3f09ae9d237c393c65/django-gravy-bitfield-1.9.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3dad288f6639acdb15ba037a7b854ca5", "sha256": "0c0eec665c680e73a5b056dddde62a2de95aebaa71d88f23f45962b593585a30" }, "downloads": -1, "filename": "django-gravy-bitfield-1.9.1.tar.gz", "has_sig": false, "md5_digest": "3dad288f6639acdb15ba037a7b854ca5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16016, "upload_time": "2016-11-24T00:05:08", "url": "https://files.pythonhosted.org/packages/70/21/ed3ffca6bb257116b621db71870c538adf9e08d48d3f09ae9d237c393c65/django-gravy-bitfield-1.9.1.tar.gz" } ] }