Django 点评:要删除用户网址,而不是扩展模型.如何? [英] Django Comments: Want to remove user URL, not expand the model. How to?

查看:15
本文介绍了Django 点评:要删除用户网址,而不是扩展模型.如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完全理解有关在 Django 中扩展评论应用程序的文档,并且真的很想坚持使用自动功能但是...

I'm totally understanding the documentation on expanding the Comments app in Django, and really would like to stick with the automatic functionality but...

在当前的应用程序中,我绝对没有使用URL"与评论一起提交.

In the current app, I have absolutely no use for an "URL" to be submitted along with a comment.

作为默认设置的微创如何防止此字段与评论表单一起显示?

使用 Django 1 或 Trunk,以及尽可能多的通用/内置插件(通用视图、默认注释设置等.到目前为止,我只有一个通用视图包装器).

Using Django 1, or Trunk, and as many generic/built-ins as possible (generic views, default comments set up, etc. I have only a single generic view wrapper so far).

推荐答案

这在 自定义评论框架.

您的应用程序将使用的是 get_form,返回 CommentForm 的子类,并弹出 url 字段.类似的东西:

All your app will use is get_form, returning a subclass of the CommentForm with the url field popped. Something like:

class NoURLCommentForm(CommentForm):
    """
    A comment form which matches the default djanago.contrib.comments one, but
    doesn't have a URL field.

    """
NoURLCommentForm.base_fields.pop('url')

这篇关于Django 点评:要删除用户网址,而不是扩展模型.如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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