7๐
โ
I found the solution when speculating this post. One should define the label
field in the custom field like the following to avoid such error AttributeError: Unable to lookup 'extra_field' on Alternative or AlternativeInline
.
class AlternativeForm(forms.ModelForm):
extra_field = forms.BooleanField(label='is_answer', required=False)
def save(self, commit=True):
# extra_field = self.cleaned_data.get('extra_field', None)
# ...do something with extra_field here...
return super(AlternativeForm, self).save(commit=commit)
0๐
To have the extra fields in the admin:
class YourModelAdmin(admin.ModelAdmin):
form = YourModelForm
fieldsets = (
(None, {
'fields': ('other fields here', 'extra_field',),
}),
)
- [Django]-Django-paypal does not receive signals
- [Django]-How to do math operations in django template?
Source:stackexchange.com