小编Dhr*_*ruv的帖子

mySQL/SQL中count(0),count(1)..和count(*)有什么区别?

我最近在接受采访时被问到这个问题.我在mySQL中尝试了这个,得到了相同的结果(最终结果).All给出了该特定表中的行数.任何人都可以解释它们之间的主要区别.

mysql sql

41
推荐指数
4
解决办法
7万
查看次数

django-rest-framework接受JSON数据?

我使用django-rest-framework创建了RESTFul API.用户端点是

/api/v1/users
Run Code Online (Sandbox Code Playgroud)

我想创建新用户.我以JSOn格式发送用户数据.

{
    "username": "Test1",
    "email": "test1@gmail.com",
    "first_name": "Test1",
    "last_name": "Test2",
    "password":"12121212"
}
Run Code Online (Sandbox Code Playgroud)

我正在使用Chrome扩展程序Postman来测试api.但用户数据尚未保存.回应是:

{
    "detail": "Unsupported media type \"text/plain;charset=UTF-8\" in request."
}
Run Code Online (Sandbox Code Playgroud)

附上截图 在此输入图像描述

python django django-rest-framework

22
推荐指数
3
解决办法
2万
查看次数

如何使用django rest框架发送文件作为响应?

我需要发送一个pdf文件和一些其他参数来响应使用django rest框架的get API调用.

我该怎么做?我尝试了这个,但它给出了一个错误<django.http.HttpResponse object at 0x7f7d32ffafd0> is not JSON serializable.

@detail_route(methods=['get'])
def fetch_report(self, request, *args, **kwargs):
    short_report = open("somePdfFile", 'rb')
    response = HttpResponse(FileWrapper(short_report), content_type='application/pdf')
    return Response({'detail': 'this works',
        'report': response})
Run Code Online (Sandbox Code Playgroud)

python api django rest django-rest-framework

8
推荐指数
3
解决办法
1万
查看次数

标签 统计

django ×2

django-rest-framework ×2

python ×2

api ×1

mysql ×1

rest ×1

sql ×1