简体   繁体   English

部署在 Heroku 上时更新 Django web 应用程序内容的最佳实践

[英]Best practice in updating Django web app content when deployed on Heroku

I'm finally at the stage of deploying my Django web-app on Heroku.我终于处于在 Heroku 上部署我的 Django 网络应用程序的阶段。 The web-app retrieves and performs financial analysis on a subset of public companies.该网络应用程序检索并执行对部分上市公司的财务分析。 Most of the content of the web-app is stored in.csv and.xslx files. web-app的大部分内容存储在.csv和.xslx文件中。 There's a master.xslx file that I need to open and manually update on a daily basis.我需要每天打开并手动更新一个 master.xslx 文件。 Then I run scripts which based on info in that.xsls file retrieve financial data, news, etc and store the data in.csv files.然后我运行基于 that.xsls 文件中的信息的脚本检索财务数据、新闻等,并将数据存储在.csv 文件中。 Then my Django views and html templates are referring to those files (and not to a sql/postgress database).然后我的 Django 视图和 html 模板引用这些文件(而不是 sql/postgress 数据库)。 This is my setup in a nutshell.简而言之,这是我的设置。

Now I'm wondering what is the best way to make this run smoothly in production.现在我想知道什么是让它在生产中顺利运行的最佳方法。

  1. Shall I store these.xslx and.csv files on AWS S3 and have Django access them and update them from there?我应该将这些 .xslx 和 .csv 文件存储在 AWS S3 上并让 Django 访问它们并从那里更新它们吗? I assume that this way I can easily open and edit the master.xslx file anytime.我假设这样我可以随时轻松地打开和编辑 master.xslx 文件。 Is that a good idea and do I run any performance or security issues?这是个好主意吗?我会遇到任何性能或安全问题吗?
  2. Is it better to convert all these data into a postgress database on Heroku?将所有这些数据转换为 Heroku 上的 postgress 数据库会更好吗? Is there a good guideline in terms of how I can technically do that?关于我如何在技术上做到这一点,是否有一个很好的指导方针? In that scenario wouldn't it be much more challenging for me to edit the data in the master.xsls file?在那种情况下,编辑 master.xsls 文件中的数据对我来说不是更具挑战性吗?
  3. Are there any better ways you would suggest to handle this?你有什么更好的方法来处理这个问题吗?

I'd highly appreciate any advice on this matter.我非常感谢您对此事的任何建议。

You need to perform a trade-off between easy of use (access/update the source XSLX file) and maintainability (storing safely and efficiently the data).您需要在易用性(访问/更新源 XSLX 文件)和可维护性(安全有效地存储数据)之间进行权衡。

Option #1 is more convenient if you need to quickly open and change the file using your Excel/Numbers application.如果您需要使用 Excel/Numbers 应用程序快速打开和更改文件,选项 #1会更方便。 On the other hand your application needs to access physical files to perform the logic and render the views.另一方面,您的应用程序需要访问物理文件以执行逻辑并呈现视图。

BTW some time ago I have created a repository Heroku Files to present some options in terms of using external files.顺便说一句,前段时间我创建了一个存储库Heroku 文件,以提供一些使用外部文件的选项。

Option #2 is typically better from a design point of view: the data is organised in the database and can be more efficiently queried and manipulated.从设计的角度来看,选项 #2通常更好:数据在数据库中组织,可以更有效地查询和操作。 The challenge in this case is that you need a way to view/edit the data, and this normally requires more development (creating new screens, etc..)这种情况下的挑战是您需要一种查看/编辑数据的方法,这通常需要更多的开发(创建新屏幕等)

Involving a database is normally the preferred approach as you can scale up to large dataset without problems (which is not the case with files).涉及数据库通常是首选方法,因为您可以毫无问题地扩展到大型数据集(文件不是这种情况)。 On the other hand if the XLS file stays small and you only need simple (quick) updates your current architecture can work.另一方面,如果 XLS 文件很小并且您只需要简单(快速)更新您当前的架构就可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 图像从部署到 heroku 的 django web 应用程序消失 - Images disappears from django web app deployed to heroku Django 应用程序在部署到 Heroku 时崩溃 - Worker 无法启动 - Django App crashes when deployed to Heroku - Worker failed to boot 在 Heroku 上准备 Django PROD 最佳实践 - Getting Django PROD ready best practice on Heroku 在部署在heroku上的Django应用中运行计划的作业 - running scheduled job in django app deployed on heroku Heroku上的Django应用程序,已成功部署但无法提供服务 - Django app on Heroku, deployed successfully but could not be served Django 模型从部署在 Heroku 中的应用程序中消失 - Django Models disappear from app deployed in Heroku 尝试访问 Django 页面时,在 Heroku 上部署了 Django 应用程序时出现错误代码 H13 - Error code H13 with Django App deployed on Heroku when trying to access Django page 使用部署到Heroku的Django应用程序时出现内部服务器错误。 该应用程序在本地工作 - I have an internal server error when using Django app deployed to Heroku. The app works locally 使用对 github repo 的新提交更新 heroku django 部署的站点 - Updating heroku django deployed site with new commits to github repo 通过Heroku部署Python应用程序时出现NoSectionError - NoSectionError when Python app is deployed via Heroku
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM