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

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -