简体   繁体   English

重新定义python模块的类/模型

[英]Redefine class/model of python module

I want to use django-achievements ( link ) module in my app, but it lack some fields in it's model. 我想在我的应用程序中使用django-achievementslink )模块,但是它的模型中缺少某些字段。 For example, I want to add CharField to it with path to picture of the badge/achievement. 例如,我想添加CharField以及徽章/成就图片的路径。 Also I will need to modify module's engine.py file for that. 另外,我将需要为此修改模块的engine.py文件。

What is the right way to do that? 什么是正确的方法? Download that module to my main app' folder and modify original files, or i can somehow redefine some methods/classes of original models.py and engine.py locally without modifing original files? 将该模块下载到我的主应用程序的文件夹中并修改原始文件,或者我可以在不修改原始文件的情况下以某种方式在本地重新定义原始models.pyengine.py某些方法/类?

I'd say fork it and make your own modifications directly to the source. 我想说一下,直接对源代码进行自己的修改。 If it's an improvement you can create a Pull Request and contribute your code to the actual repository (not required, you can always just keep it for your own use). 如果有改进,可以创建一个“拉取请求”,并将代码贡献到实际的存储库中(不是必需的,您始终可以保留它供自己使用)。

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

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