django-bitfield

BitField in Django
Download

django-bitfield Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Other/Proprietary Li...
  • Publisher Name:
  • DISQUS
  • Publisher web site:
  • http://disqus.com

django-bitfield Tags


django-bitfield Description

BitField in Django django-bitfield is a Django app that provides a BitField like class (using a BigIntegerField) for your Django models.InstallationInstall it with pip (or easy_install):pip install django-bitfieldUsageFirst you'll need to attach a BitField to your class. This acts as a BigIntegerField (BIGINT) in your database:from bitfield import BitFieldclass MyModel(models.Model): flags = BitField(flags=( 'awesome_flag', 'flaggy_foo', 'baz_bar', ))Now you can use the field using very familiar Django operations:# Create the modelo = MyModel.objects.create(flags=0)# Add awesome_flag (does not work in SQLite)MyModel.objects.filter(pk=o.pk).update(flags=MyModel.flags.awesome_flag)# Set flags manually to MyModel.objects.filter(pk=o.pk).update(flags=3)# Remove awesome_flag (does not work in SQLite)MyModel.objects.filter(pk=o.pk).update(flags=~MyModel.flags.awesome_flag)# Test awesome_flagif o.flags.awesome_flag: print "Happy times!"# List all flags on the fieldfor f in o.flags: print f Requirements: · Django · Python


django-bitfield Related Software