Django评论:想删除用户URL,不扩展模型。如何? [英] Django Comments: Want to remove user URL, not expand the model. How to?

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

问题描述

我完全理解了在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 ,返回带有url字段弹出的 CommentForm 的子类。类似于:

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评论:想删除用户URL,不扩展模型。如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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