scripts: start utils module
This commit is contained in:
parent
ebddd10a2e
commit
58ebd8fb64
|
@ -0,0 +1,9 @@
|
|||
|
||||
class QuerysetIndex(object):
|
||||
'''Create simple index of objects in a queryset'''
|
||||
def __init__(self, qs, *keywords):
|
||||
for keyword in keywords:
|
||||
setattr(self, 'by_' + keyword, dict())
|
||||
for obj in qs:
|
||||
for keyword in keywords:
|
||||
getattr(self, 'by_' + keyword)[getattr(obj, keyword)] = obj
|
Reference in New Issue