I would, but in this case, I want to remove a field in an external app
(specifiaclly, django-registration).  I suppose I could extract all
the relevant parts out of the form class in django-registration and
paste it into my own form, but that seems really redundant.

Basically, the user's name is autogenerated from the email field, so I
want to remove the username field from the django-registration form.

Though I suppose if there's no good way of doing it, I'll just have to
copy out the relevant bits into a new form.

-- dz



On Fri, Feb 20, 2009 at 7:20 PM, Malcolm Tredinnick
<[email protected]> wrote:
>
> 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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to