Is the exclude list in a ModelForm any different from an exclude list in a ModelAdmin? If my ModelForm is tied to the ModelAdmin, where do I need to specify the e开发者_开发知识库xclude list ideally; in the ModelForm Meta class or in the ModelAdmin subclass?
Depends if you want to do something else with the form. If its displayed somewhere else than the admin and you want to exclude the same field there as well, define it in the ModelForm. If the ModelForm is just used in the admin and nowhere else you basically can choose what makes more sense for you. I personally would still keep it in the ModelForm so this functionality is tied to it instead to the admin.
Edit (see comments below):
Apparently there seems to be a bug in Django. If I exclude something in a ModelForm and then use this form in the ModelAdmin it is still showing this field for some reason. You better exclude in the admin only to be 100% sure or specify fields
in the ModelForm without the field you want to exclude.
精彩评论