Django Pinax,扩展捆绑应用程序

发布于 2024-12-02 08:54:56 字数 163 浏览 3 评论 0原文

我想将 Pinax 用于一个小项目,但我很困惑,因为我不知道是否可以扩展/更改所提供应用程序的行为和功能。 是否有任何文档可以扩展捆绑应用程序的行为?

示例:在注册应用程序中,我想添加自定义字段,但我无法找到有关如何实现它的正确文档..(主要针对那些需要数据库更改的人)

谢谢!

I want to use Pinax for a small project , but I am confused because I don't if can extend/change the behavior and functional of the provided applications .
Is there any documentation for extending the behavior of the bundled applications ?

example: in registration application ,I want to add custom fields but I am not able to find proper documentation on how to achieve it..( mainly for those which need db changes )

Thanks !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冰雪之触 2024-12-09 08:54:56

是的,您可以扩展内置应用程序的行为。如果您将 pinax 基本设置与用户帐户和配置文件一起使用,则必须在 apps/profiles/models.py 中添加所需的额外字段。有关字段类型的列表,请参阅此处:https://docs.djangoproject。 com/en/1.3/ref/models/fields/

当您运行manage.pysyncdb时,这将为您创建必要的数据库字段。但是,如果您已经同步了数据库,则必须手动添加数据库列。如果该表中没有任何您关心的数据,您可以随时删除该表,它会重新创建它。一旦创建了数据库表,Django 就不会修改它们,即使您更改了模型。

您还必须修改注册表单以包含这些新字段,并将 urls.py 指向您创建的新注册表单。将表单从 site-packages/pinax 目录复制到您的项目。不要直接修改它们。

如果您还没有,您应该在此处查看 Django 教程: https:// docs.djangoproject.com/en/1.3/intro/tutorial01/

这将使您很好地了解 Django 应用程序如何组合在一起以及不同部分如何交互,因此您可以更好地自定义 Pinax你的喜好。确保您知道 models.pyurls.pyviews.py 和模板正在做什么。

Yes, you can extend the behaviour of the built-in applications. If you are using the pinax basic setup with user accounts and profiles, you will have to add the extra fields you want in apps/profiles/models.py. For a list of field types, see here: https://docs.djangoproject.com/en/1.3/ref/models/fields/

This will create the necessary db fields for you when you run manage.py syncdb. If you have already sync'd the db, however, you will have to manually add the db columns. If you don't have any data you care about in that table, you can always just drop the table and it will recreate it. Django doesn't modify db tables once they are created, even if you change the model.

You will also have to modify the signup form to include these new fields and point your urls.py to the new signup form you created. Copy the form from the site-packages/pinax directory to your project. Don't modify them directly.

If you haven't already, you should check out the Django tutorial here: https://docs.djangoproject.com/en/1.3/intro/tutorial01/

This will give you a good idea of how Django apps are put together and how the different pieces interact, so you can do a better job customizing Pinax to your liking. Make sure you know what models.py, urls.py, views.py, and the templates are doing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文