Django-小知識點

一:獲取url路徑

相似url:  http://127.0.0.1:8001/customer_edit/2?next=/customer_list/前端

1:如何獲取整個url:

  前端獲取方法:location.href========http://127.0.0.1:8001/customer_edit/2?next=/customer_list/app

 

2:如何獲取url參數:

  前端獲取方法:location.search====?next=/customer_list/url

  那麼如何獲取next後面的路徑:location.search.slice(6)spa

 

二:Django項目中文件訪問順序

setting.py定義的如靜態文件目錄。Django先是從全局中查找,若是找不到。而後再從各個應用中查找,安裝setting.py定義的中間件的順序code

 

 

 

三:如何獲取類名(字符串形式)

 

    from school.models import Student

    print(Student._meta.model_name)  #student  類名
    print(Student._meta.app_label)  #school  應用名字
相關文章
相關標籤/搜索