FBV

  • FBV 基于函数的视图

  • 例子

    • urls.py

      urlpatterns = [
          url(r'^admin/', admin.site.urls),
          url(r'^index/', views.index)
      ]
      
    • views.py

      # 简单的例子
      def index(request):
          return render(request, 'index.html')
      
      # 如果判断请求方式
      def index1(request):
        # 判断是不是post请求
        if request.method == 'POST':
          pass
        return render(request,'index.htmlsss')
      

results matching ""

    No results matching ""