def delete_model_JSON(request,model_klass, model_id): """ Generic JSON view for model deletion. Returns a status indicator and the model JSONized. """ model = get_object_or_404(model_klass, pk=model_id) model_dump = instance_to_dict(model) model.delete() return JSONResponse({'status': 'ok', 'object': model_dump})
def delete_model_JSON(request, model_klass, model_id): """ Generic JSON view for model deletion. Returns a status indicator and the model JSONized. """ model = get_object_or_404(model_klass, pk=model_id) model_dump = instance_to_dict(model) model.delete() return JSONResponse({'status': 'ok', 'object': model_dump})
def to_dict(self, with_tags=False, **kwargs): d = instance_to_dict(self) if with_tags: d.update({'tags_by_category': self.tags_by_category()}) return d
def tags_by_category(self): output = {} for tag in self.tags.all(): append_to_key(output, tag.category.name, instance_to_dict(tag)) return output
def to_dict(self): return instance_to_dict(self)
def to_dict(self, with_tags=False, **kwargs): d = instance_to_dict(self) d.pop('source_id') d['audiosource'] = self.source.to_dict() return d