我在 django 项目中使用 ckeditor。 我在包的 View 中(在 ckeditor_uploader 中)做了一些代码定制。
如果我现在部署到生产服务器,我需要包含我在包中所做的更改(位于 lib/site-packages...)。
什么是好方法?
我只看到这个选项: a) 使用编辑器修改生产服务器上已安装的包。
还有其他选项可以让我将更改后的代码保留在我的实际项目中(通过 github 存储和部署)吗?
最佳答案
修改包对你没有任何好处。相反,您应该对 View 进行子类化并重写需要表现不同的方法。
from ckeditor_uploader import ImageUploadView
class MyCustomView(ImageUploadView):
def post(self, request, **kwargs):
# do something different here,
# then hand things over to
# the original parent
return super(MyCustomView, self).post(request, **kwargs)
关于python - django:需要修改已安装包中的 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35187723/