Re: Subclassing CommentForm

2009-02-07 Thread Shantp

Wow. Just removing the () after my subclassed commentform worked.
Thanks a lot. I hope that ticket is completed soon and added into
django.

On Feb 7, 8:31 pm, Eric Abrahamsen  wrote:
> On Feb 8, 2009, at 12:15 PM, Shantp wrote:
>
>
>
>
>
> > Hi,
>
> > I've got a custom comment form in my template using "get_comment_form"
> > and I'd like email to not be required. From some searching I see that
> > I need to subclass the CommentForm, but I don't know exactly how to go
> > about this. Here's what I put into my forms.py
>
> > from django.contrib.comments.forms import CommentForm
> > class EmailFreeCommentForm(CommentForm):
> >    email = forms.EmailField(label='Email address', required=False)
>
> > Then I put this in my urls.py
>
> > from django.contrib import admin, comments
> > from sharing.forms import EmailFreeCommentForm
> > def override_get_form():
> >    return EmailFreeCommentForm()
>
> > comments.get_form = override_get_form
>
> > This is giving me errors. Am I missing something?
>
> This is how I do it:
>
> def my_get_form():
>      return MyCommentForm
>
> comments.get_form = my_get_form
>
> This is a monkeypatch and not the way it should be done, but full  
> customizability for the comments app is a work in progress (see ticket  
> #8630http://code.djangoproject.com/ticket/8630), and until that's  
> finished I think this is what people are doing.
>
> Yours,
> Eric
>
> > If you can point me towards good subclassing docs that would be
> > appreciated as well. Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Subclassing CommentForm

2009-02-07 Thread Shantp

Hi,

I've got a custom comment form in my template using "get_comment_form"
and I'd like email to not be required. From some searching I see that
I need to subclass the CommentForm, but I don't know exactly how to go
about this. Here's what I put into my forms.py

from django.contrib.comments.forms import CommentForm
class EmailFreeCommentForm(CommentForm):
email = forms.EmailField(label='Email address', required=False)

Then I put this in my urls.py

from django.contrib import admin, comments
from sharing.forms import EmailFreeCommentForm
def override_get_form():
return EmailFreeCommentForm()

comments.get_form = override_get_form

This is giving me errors. Am I missing something?

If you can point me towards good subclassing docs that would be
appreciated as well. Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---