-
-
Save pielgrzym/1027029 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MortgageForm(ModelForm): | |
class Meta: | |
model = Mortgage | |
def __init__(self, *args, **kwargs): | |
""" | |
Custom init method | |
""" | |
import ipdb | |
ipdb.set_trace() | |
super(MortgageForm, self).__init__(*args, **kwargs) | |
commentable_fields = [] | |
if hasattr(self._meta.model, "_commentable_fields"): | |
commentable_fields = self._meta.model._commentable_fields | |
for i, field in enumerate(self.fields): | |
if field in commentable_fields: | |
cf = forms.fields.CharField(label='comment_%d' % i) | |
cf.is_hidden = False | |
self.Meta.fields.insert(i+1, cf) | |
class MortgageAdmin(admin.ModelAdmin): | |
inlines = [ | |
# inlines here | |
] | |
form = MortgageForm | |
fields = [ | |
# field list here | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment