que no puedo comentar sobre el poste SmileyChris' por alguna razón, así que voy a publicar aquí. Pero me encontré con errores usando solo la respuesta de SmileyChris. También debe sobrescribir la función get_comment_create_data porque CommentForm buscará las claves Post que haya eliminado. Así que aquí está mi código después de eliminar tres campos.
class SlimCommentForm(CommentForm):
"""
A comment form which matches the default djanago.contrib.comments one, but with 3 removed fields
"""
def get_comment_create_data(self):
# Use the data of the superclass, and remove extra fields
return dict(
content_type = ContentType.objects.get_for_model(self.target_object),
object_pk = force_unicode(self.target_object._get_pk_val()),
comment = self.cleaned_data["comment"],
submit_date = datetime.datetime.now(),
site_id = settings.SITE_ID,
is_public = True,
is_removed = False,
)
SlimCommentForm.base_fields.pop('url')
SlimCommentForm.base_fields.pop('email')
SlimCommentForm.base_fields.pop('name')
Esta es la función que va a sobrescribir
def get_comment_create_data(self):
"""
Returns the dict of data to be used to create a comment. Subclasses in
custom comment apps that override get_comment_model can override this
method to add extra fields onto a custom comment model.
"""
return dict(
content_type = ContentType.objects.get_for_model(self.target_object),
object_pk = force_unicode(self.target_object._get_pk_val()),
user_name = self.cleaned_data["name"],
user_email = self.cleaned_data["email"],
user_url = self.cleaned_data["url"],
comment = self.cleaned_data["comment"],
submit_date = datetime.datetime.now(),
site_id = settings.SITE_ID,
is_public = True,
is_removed = False,
)
Acepto la documentación es grande, pero tengo que argumentar que encontrar mi camino a "base_fields" y usar. pop() no fue algo que encontré fácilmente. Sí, el marco de comentarios está bien documentado, pero "esto" no es así. Estoy de acuerdo en que es mi responsabilidad encontrar ese tipo de cosas, ¡y estoy muy agradecido por su tiempo y asistencia! ¡Gracias hermano! –
Esto arroja errores en Django 1.4. También debe sobrescribir el método get_comment_create_data como se menciona en la solución de killerbarney. –