Ejemplo n.º 1
0
    def __init__(self, *args, **kwargs):
        super(AjaxQuestionForm, self).__init__(*args, **kwargs)
        from ajax_select import fields as afields

        # The above may fail, obviously, if you don't have ajax select
        self.fields['title'] = afields.AutoCompleteField('question')
        self.fields['title'].widget.attrs.update(
            {'style': 'width:400px;font-size:18px'})
class BookForm(ModelForm):
    class Meta:
        model = Book
        fields = ['name', 'author', 'mentions_persons']

    name = fields.AutoCompleteField('name')
    author = fields.AutoCompleteSelectField('author')
    mentions_persons = fields.AutoCompleteSelectMultipleField('person')