On Fri, 2009-02-20 at 10:15 -0500, David Zhou wrote:
> Suppose I had this form:
> 
> class BaseForm(forms.Form):
>     field1 = forms.CharField(...)
>     field2 = forms.Charfield(...)
> 
> And then in a subclass, I had:
> 
> class SubForm(BaseForm):
>     field1 = forms.EmailField(...)
> 
> What's a good way to remove field2 in SubForm? 

Wrong question. Reconsider your class structure. Inheritance says that
SubForm "is-a" version of BaseForm. However, your question is asking how
you can actually break that constraint by removing one of the necessary
parts of BaseForm. So it isn't really a subclass after all.

If there are common elements between BaseForm and SubForm, then factor
out those common bits into a true base class that both BaseForm and
SubForm inherit from.

Regards.
Malcolm




--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to