how do django forms work

I am learning Django. Particularly I am reading about forms and I cannot understand how do they work. Lets look at example code:

from django import forms

class ContactForm(forms.Form):
    subject = forms.CharField(max_length=100)
    message = forms.CharField()
    sender = forms.EmailField()
    cc_myself = forms.BooleanField(required=False)

why create class with unbounded members? there is no self statement.

I looked on Django source code itself:

class Form(BaseForm):
"A collection of Fields, plus their associated data."
# This is a separate class from BaseForm in order to abstract the way
# self.fields is specified. This class (Form) is the one that does the
# fancy metaclass stuff purely for the semantic sugar -- it allows one
# to define a form using declarative syntax.
# BaseForm itself has no way of designating self.fields.
__metaclass__ = DeclarativeFieldsMetaclass

Could you explain what is the role of __metaclass__ ?


The form fields are descriptors, which are simply a class written to a specific protocol. The metaclass is the type of the class (since classes themselves, being objects, are instantiated from something).

Need Your Help

Tab Control Accessing each tab member Winform

c# .net winforms tabcontrol

How can I hide a button when a specific tab is clicked?

Converting a char to gchar

c gtk char

So, heres the deal, I'm using GTK on this one.

can anyone tell flow of execution of blocks in objective c?

objective-c objective-c-blocks

Hi iam working with Blocks in objective-c. I have just learn syntax, and how to write blocks. But i didn't understand execution flow. I googled it for flow of execution, i can't find.