django:修改/扩展第三方应用程序 [英] django: modifying/extending 3rd party apps

查看:167
本文介绍了django:修改/扩展第三方应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个新手django问题

a newbie django question

我想使用第三方应用程序,但我需要做一些mods(在这种情况下,应用程序是django注册,而且我需要改变一些事情,例如允许注册而不需要确认电子邮件)

I want to use 3rd party app, but I need to make some mods to it (in this case, the app is django-registration, and I need to change things such as allowing registration without confirmation email)

最初,我只是在普通的site-packages文件夹中安装了应用程序,并在那里更改了代码。现在我将我的代码放在bitbucket上,我需要一种方法才能以可用的方式将我的mod保存在存储库中,并且上传完整的python代码听起来不是个好主意。

Initially, I simply installed the app in the general site-packages folder, and changed the code there. Now that I put my code on bitbucket I need a way to be able to keep my mods in the repository in a usable way, and uploading the full python code doesn't sound like a good idea.

我想最好的办法是将第三方应用程序保留在网站包中,并在我的项目中创建一个应用程序来保留我的更改。在我的情况下,我将在我的项目中创建我的django注册,然后在我的代码中需要它时导入,而不是django注册。

I guess the best way would be to keep the 3rd party app in site-packages, and create an app in my project to keep my changes. In my case, I'd create my-django-registration in my project, and then import this when I need it in my code, rather than django-registration.

我也阅读了关于virtualenv,但是我认为这主要用于在同一台机器上使用多个环境(实际上,它建议不要更改在virtualenv中安装的模块),并且不能帮助我保持我的更改在资料库中。

I also read about virtualenv, but I think that's mostly used for being able to use multiple environments in the same machine (in fact, somewhere it advises against changing the modules installed in the virtualenv), and doesn't help me with keeping my changes in a repository.

欢迎任何意见!
谢谢

Any comments welcome! Thanks

推荐答案

我认为完成你想要的最完美的方法是fork django-registration,在您的应用程序中使用fork而不是原始项目。

I think the neatest way to accomplish what you look for would be to fork django-registration, and in your app use the fork instead of the original project.

据说,您可以在django注册中进行非电子邮件注册,而无需更改应用程序的代码。我已经创建了一个自定义的注册后端将用户设置为激活创建时。 在这里,您可以看到其他方法来做同样的事情。

That being said, you can have a non-email registration in django-registration without changing the code of the app. I've done it by creating a custom registration backend that sets the users as activated upon creation. Here you can see other ways to do the same.

这篇关于django:修改/扩展第三方应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆