Is it possible to have a field on a Django form that does not either exist in the database, and/or update when the form is updated?
I tried something like this, examples of which were online, but those examples didn’t have
Meta in the class:
class ItemFormBarcode(forms.ModelForm): category = forms.ChoiceField(choices=Item.category_displaychoices, widget=forms.RadioSelect) extra_field = forms.IntegerField() class Meta: model = Item fields = ( 'extra_field', 'barcode', 'category', 'group', 'title', 'description', 'price', 'imgurl', )
If I put
extra_field in the
fields list I get the error:
django.core.exceptions.FieldError: Unknown field(s) (extra_field) specified for Item
If it is not in the
fields list is obviously does not show.
My alternative at the moment is to fire a process after the save to remove the data in the field.