def snippet_list(request):
"""
list all the code snippets ,or create a new snippet.
"""
if request.method == 'GET':
snippet = Snippet.object.all()
serializer = SnippetSerializer(snippets, many = True)
return JSONResponse(serializer.data)
elif request.method == 'POST':
data = JSONParser().parse(request)
serializer = SnippetSerializer(data =data)
if serializer.is_valid():
serializer.save()
return JSONResponse(serializer.data,status =201)
return JSONResponse(serializer.errors,status=400)
您正在混合制表符和空格:
线表示制表符,点表示空格。Python将选项卡扩展到每第8列。你知道吗
不要混合制表符和空格,将制表符转换回空格,并将编辑器配置为仅使用空格进行缩进。你知道吗
您可以将大多数编辑器配置为仅使用空格进行缩进;这是Python styleguide (PEP 8)建议的:
相关问题 更多 >
编程相关推荐