# передача параметра (как вариант)
def mess_convert(el):
SymTo2Bin = ConvertFromDec(el, 10, 2)
RSLength = len(SymTo2Bin[2:])
TMessage = ''
while RSLength < 9:
TMessage += "0"
RSLength += 1
TMessage += SymTo2Bin[2:]
MMessage.append([TMessage[d:d + 3] for d in range(0, len(TMessage), 3)])
return MMessage
def mess():
for sym in Message:
mess_convert(ord(sym)
mess_convert(len(Message))
SELECT model, COUNT(model) AS Qty_model,
AVG(price) AS Avg_price
FROM PC
GROUP BY model
HAVING AVG(price) < 800;
class FileUploadView(APIView):
parser_classes = (FileUploadParser, )
def post(self, request, format='ваш формат'):
file = request.FILES['file']
_ = open('/path/' + up_file.name, 'wb+')
for chunk in up_file.chunks():
_.write(chunk)
_.close()
# или
class ExampleViewSet(ModelViewSet):
queryset = Example.objects.all()
serializer_class = ExampleSerializer
def pre_save(self, obj):
obj.file = self.request.FILES.get('file')