1

This question almost seems like too much of a hassle to ask, so if I don't provide enough details, I'm sorry. I'm using a bunch of different things in this project so to provide details on all of it would take me half the day. If there's something specific that'll help you target the solution, please ask.

I have a formset view, with a complicated pipeline. In my form view, I use ModelFormsetView from django extra views. I imagine the error must be in that code somewhere, but if I look in their code it has both "exclude" and "fields" at every step and never does it leave one out.

fields = ('name', 'toggle_on', )

instead of

exclude = ('created', 'modified', )

It will always include "created" and "modified." If I do exclude, it always works. The django docs say to use "fields" instead of "exclude".

I know there are a bunch of other variables in a pipeline like this, but since changing it from fields to exclude solves it, it's got to be something wrong with the form.

Also I should mention that Allocation is the child class of a polymorphic model called category, so that's why I have to deal with "category_ptr".

As requested, I'm posting form code.

class AllocationFormBudget(FilterDestinationBudget):
    start_date = forms.DateField(widget=DateInput(), required=True, initial=date.today())
    end_date = forms.DateField(widget=DateInput(), required=False)

class Meta:
    model = Allocation
    #fields = ('name', 'source_account', 'minimum', 'additional_amount', 'toggle_on', 'broad_category', 'start_date',
    #          'match_source_account_period', 'allocation_dates', 'flexible_percent', 'payment_type')
    exclude = ('created', 'modified', 'reimbursable_percent', 'category_ptr', 'end_date', 'destination',
               'transaction_identifiers', )

def __init__(self, *args, **kwargs):
    super(AllocationFormBudget, self).__init__(*args, **kwargs)
    self.fields['match_source_account_period'].widget.attrs = {'class': 'Match_Account'}


class FilterDestinationBudget(forms.ModelForm):
    name = forms.CharField(widget=forms.TextInput(attrs={'size': '20'}))
    minimum = forms.DecimalField(widget=forms.TextInput(attrs={'style': "width: 7em", 'type': 'number', 'step': '0.01'}),
                             initial=0.00)
    additional_amount = forms.DecimalField(widget=forms.TextInput(attrs={'style': "width: 7em", 'type': 'number',
                                                                     'step': '0.01'}), initial=0.00)
    flexible_percent = forms.DecimalField(widget=forms.TextInput(attrs={'style': "width: 7em", 'type': 'number',
                                                                    'step': '0.01'}), initial=0.00, required=False)

def __init__(self, *args, **kwargs):
    super(FilterDestinationBudget, self).__init__(*args, **kwargs)
    self.fields['source_account'].widget = forms.HiddenInput()
    self.fields['broad_category'].widget.attrs.update({'class': 'BC_Dropdown'})
mastachimp
  • 438
  • 3
  • 14

0 Answers0