def __getitem__(self, key):
    return self.model.objects.get(key=key)

def __setitem__(self, key, item):
    pair = self.model()
pair.key = key
pair.value = item
pair.save()

def __contains__(self, key):
    pass
Django: Converting an entire set of a Model's objects into a single dictionary