本地调试django代码的方法

find_case.py文件:

#coding=utf-8

class MyClass(object):
	def getFileAll(self,request):
		......
		
		return  HttpResponse('success')

 

urls.py:

urlpatterns = [
    
    url(r'^admin/', admin.site.urls),    
    url(r'^media/(?P<path>.*)$', serve, {"document_root": MEDIA_ROOT}),
    url(r'^api-auth/', include('rest_framework.urls',namespace='rest_framework')),
    url(r'^',include(router.urls)),
    
    url(r'^getFileAll$',MyClass().getFileAll,name='getFileAll'),

]

 

启动django:

  

 打开浏览器访问:http://127.0.0.1:8000/getFileAll

 查看调试日志:

 

原文地址:https://www.cnblogs.com/apple2016/p/14308119.html