路径问题
位于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’