djangosnippets.org: Latest snippets tagged with 'bitwise'https://djangosnippets.org/tags/bitwise/2010-05-05T13:57:27.202409-05:00Bitwise operator queryset filter
2010-05-05T13:57:27.202409-05:00hgeerts@osso.nlhttps://djangosnippets.org/snippets/2008/<p>This snippet for django-1.2 allows you to use bitwise operators without using QuerySet.extra()</p>
<pre><code>from django.db.models import *
from somewhere import FQ
class BitWise(Model):
type = CharField(max_length=8)
value = IntegerField()
def __unicode__(self):
return '%s - %d' % (self.type, self.value)
>>> BitWise.objects.create(type='django', value=1)
<BitWise: django - 1>
>>> BitWise.objects.create(type='osso', value=3)
<BitWise: osso …</code></pre>
Freely redistributable