zoukankan      html  css  js  c++  java
  • 路径问题

    位于syl/settings

    1.1操作系统文件绝对路径

    import os
    print(os.path.abspath(__file__))                                                               #/root/day/day08/syl/syl/settings.py

    print(os.path.dirname(os.path.abspath(__file__)))                                   #/root/day/day08/syl/syl

    print(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))       #/root/day/day08/syl

    STATIC_URL='/static/'


    2导包路径

    import sys
    print(sys.path)

    ['/root/day/day08/syl/syl', '/root/day/day08', '/root/day/day08/celery_task', '/root/day/day08/syl', '/root/day/day08/syl/apps', '/root/day/day08/syl/libs', '/sortware/pycharm/plugins/python/helpers/pycharm_display', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/root/.virtualenvs/syl/lib/python3.6/site-packages', '/sortware/pycharm/plugins/python/helpers/pycharm_matplotlib_backend']


    sys.path.insert(0,os.path.join(BASE_DIR,'apps'))


    print(sys.path)

    ['/root/day/day08/syl/apps', '/root/day/day08/syl/syl', '/root/day/day08', '/root/day/day08/celery_task', '/root/day/day08/syl', '/root/day/day08/syl/apps', '/root/day/day08/syl/libs', '/sortware/pycharm/plugins/python/helpers/pycharm_display', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/root/.virtualenvs/syl/lib/python3.6/site-packages', '/sortware/pycharm/plugins/python/helpers/pycharm_matplotlib_backend']

    3 django 模型引用路径

    想要用一个models.py 文件中的模型

    apps名称.model模型名

    ‘users.User’

  • 相关阅读:
    Go语言
    Go语言
    electron-builder vue3 用户自定义安装目录
    提取页面中的style标签内容
    px2rpx | px转rpx
    js EventBus
    select 下拉选择多个值
    keep-alive页面缓存
    js适配移动端页面
    vue日常问题记录
  • 原文地址:https://www.cnblogs.com/xiaoxiamiaichiyu/p/13885312.html
Copyright © 2011-2022 走看看