Previous Page Next Page

Q&A

Q.Is there a way to find out what model is associated with a Form instance?
A.Yes. The model can be accessed using the _model of the Form instance. Here's an example:
objClass = ContactForm._model

Q.Can I create my own Widget?
A.Yes. The following code defines a custom TextInput Widget that can be used in Forms:
class myWidget(forms.TextInput):
    def __init__(self, *args, **kwargs):
    kwargs.setdefault('attrs', {}).update({'size': '60'})
    super(myWidget, self).__init __(*args, **kwargs)

Previous Page Next Page