django - Create a non-model form field in my model form filed -
i'm hoping makes sense, here want (for whatever reason).
i create non-model form field within model form?
for example, below have model form, @ init add extra field that's not contained within model called template. don't save new field not need in model or want (i fancy ajax stuff it.).
forms.py
class testform(forms.modelform): def __init__(self, user=none, *args, **kwargs): super(testform, self).__init__(*args, **kwargs) if user not none: this_templates = template.objects.for_user(user) self.fields["templates"] = forms.??????????
you there:
self.fields["templates"] = forms.charfield()
or if prefer field type check the documentation possible options.
and additional background information take @ overloading django form fields.
Comments
Post a Comment