From 3ca335090774c8d97ef74b66eaa4370838bebe84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Cort=C3=A8s?= Date: Sat, 22 Nov 2014 12:44:56 +0100 Subject: [PATCH] allow to customize the model form directly on the model declaration. --- inplaceeditform/fields.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/inplaceeditform/fields.py b/inplaceeditform/fields.py index 6b75cda..5c5c1cf 100644 --- a/inplaceeditform/fields.py +++ b/inplaceeditform/fields.py @@ -106,7 +106,20 @@ def get_config(self, request, **kwargs): return config def get_form_class(self): - return modelform_factory(self.model) + + kwargs = {} + + fields = getattr(self.model, 'INPLACEEDIT_FIELDS', None) + + if fields: + kwargs['fields'] = fields + + exclude = getattr(self.model, 'INPLACEEDIT_EXCLUDE', None) + + if exclude: + kwargs['exclude'] = exclude + + return modelform_factory(self.model, **kwargs) def get_form(self): form_class = self.get_form_class()