这篇文章主要介绍了关于pycharm 将django中多个app放到同个文件夹apps的处理方法,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下
在django中需要创建多个app,这个就需要创建一个apps文件,把所有的app放到同个文件夹,这个比较清楚,看起来也比较规范
首先在项目文件右击—–new–python package创建一个apps文件,把所有的app拖入到apps,

弹出对话框把search for references和open moved files in editor不勾选,点击确认,这个时候运行点击run,会出现运行错误
in check_apps_ready
 raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.这时候需要对apps的文件夹右击–选择mark directory as—-选择sources root,再点击run,就可以正常运行了

这个时候基本可以在pycharm中正常使用,但是如果部署的实际环境中就不能这样,需要在setting.py文件中加入
sys.path.insert(0,os.path.join(BASE_DIR,'apps'))
这样就可以在实际部署中正常使用。
以上就是pycharm 将django中多个app放到同个文件夹apps的处理方法的详细内容,更多请关注php中文网其它相关文章!
 
                        
                        每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
 
                Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号