简体   繁体   English

我们如何在 Django 中创建插件和播放架构?

[英]How Can we Create a plugin and Play Architecture in Django?

Actually, I want to create a plug and play architecture in Python Django.实际上,我想在 Python Django 中创建一个即插即用的架构。 I have a different kind of scrapers and I am writing more scrapers too.我有一种不同的刮板,我也在写更多的刮板 Whenever I build a new scraper I have to again publish my repo in production.每当我构建一个新的刮板时,我都必须再次在生产中发布我的 repo。 What I need I just want to plug that new scraper without actually again deploying my code.我需要什么我只想插入那个新的刮刀而不实际再次部署我的代码。 I have already used the GitHub versioning system but I am in need of a more clean way.我已经使用了 GitHub 版本控制系统,但我需要一种更简洁的方式。 Thanks in advance.提前致谢。

What you should be doing is Generating the Setup.py File which would automatically set it up as a package thus, When the User would run the Setup.py File,您应该做的是生成 Setup.py 文件,它会自动将其设置为一个包,因此,当用户运行 Setup.py 文件时,

It would deploy it as a package.它会将它部署为一个包。 Second Thing is you can create a Package out of It with the tools already provided by Python to create a Package of an App in Django.第二件事是您可以使用 Python 已经提供的工具从中创建一个包,以在 Django 中创建一个应用程序包。

Packaging a Python Script: https://the-hitchhikers-guide-to-packaging.readthedocs.io/en/latest/quickstart.html https://pythonhosted.org/an_example_pypi_project/setuptools.html打包 Python 脚本: https : //the-hitchhikers-guide-to-packaging.readthedocs.io/en/latest/quickstart.html https://pythonhosted.org/an_example_pypi_project/setuptools.html

For Django, Follow below Steps:对于 Django,请按照以下步骤操作:

  1. Initilize it with a ReadMe File用自述文件初始化它
  2. Initilize it with a MANIFEST.in to include the text files and static files in our package使用 MANIFEST.in 初始化它以在我们的包中包含文本文件和静态文件
  3. run python setup.py build Reference: https://www.pythoncentral.io/package-python-django-application-reusable-component/ Now Simply Use it anywhere You Wish making it a Reusable App!运行python setup.py build参考: https : //www.pythoncentral.io/package-python-django-application-reusable-component/现在只需在任何你希望使它成为可重用应用程序的地方使用它!

Reference for a Package Settled Up: https://github.com/smfai200/rebound安装包参考: https : //github.com/smfai200/rebound

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM