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  应用名字
相关文章
相关标签/搜索