python - 访问变量到另一个应用程序 django
问题描述
我在 Django 中有两个应用程序
├── search
│ └── views.py
│
└── preprocessing
└── views.py
在 search/views.py 中,我有如下代码的数据框:
df = pd.DataFrame()
def scrape(request):
global df
items = comments + replies
df = pd.DataFrame(items, columns=['Comments'])
return render(request, 'search/scrape.html', context)
而且,我想在第二个应用程序中使用来自 search/views.py 的数据框
预处理/views.py
from search.views import df
def index(request):
print(df)
context = {
}
return render(request, 'preprocessing/preprocessing.html')
但问题是我传递给 preprocessing/views.py 的数据框是空的,所以,我怎样才能通过 datframe 中的值也来自 search/views.py thx 寻求帮助
解决方案
推荐阅读
- javascript - 如何在不暴露令牌的情况下从客户端的 twitter api 获取推文
- reactjs - 动态链接——在生产中使用 React 实现真正的模块化
- html - 网站未在服务器上加载 CSS - net::ERR_ABORTED 404
- mysql - 在 Node.js 中从 MySQL 读取原始 JSON 数组
- python - 使用从数组中读取的值作为变量
- wpf - Azure DevOps - 有没有办法在管道中发布 Fx4.8 WPF 应用程序?
- python - 如何在不迭代的情况下获取列表中的下一行元素
- javascript - 使用赛普拉斯 IO 将返回的值保存在 URI 或对测试上下文的响应中
- javascript - 使用 jquery/regex 从字符串中的数字前删除 0
- c++ - 使用 C++ 打印从 SQLite3 数据库中检索到的数据,方式与命令行相同