Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AttributeError: 'JsonResponse' object has no attribute 'all_records'
- from sanic.response import json
- from sanic.views import HTTPMethodView
- from models.project import Project
- from helpers.json import JsonResponse
- class ProjectListResource(HTTPMethodView):
- def get(self, resp):
- projects = Project().select().dicts()
- return JsonResponse(projects, all_records=True)
- from sanic.response import json
- class JsonResponse:
- def __init__(self, model, all_records=None):
- self.model = self._model_query(model)
- self.all_records = all_records
- def _model_query(self, model):
- if self.all_records:
- records = json({model: list(model)})
- else:
- records = {}
- return records
- def __init__(self, model, all_records=None):
- self.all_records = all_records # Сначала эта строка
- self.model = self._model_query(model) # И только потом эта
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement