3

Okay. I am probably just overlooking something silly. But I am having an issue with an inline form in django. I have this:

class BaseModelAFormset(forms.models.BaseInlineFormSet):
    def clean(self):
        for form in self.forms:
            print 'I am getting here'

ModelAFormset = inlineformset_factory(ModelB,ModelA, extra=1, formset=BaseModelAFormset)

My models are not really named ModelA and ModelB. I did that as an example.

Anyway, I have this formset on a page and have 2 forms in it plus a third blank one. (So two of the three forms are filled in with objects.

I hit save and I'd expect to see two "I am getting here" statements, but I only see one.

In the end, I am doing a count check for validation, but if the second form is never checked, my count check won't do much good. So the print statement is an intermediate step towards that. Anyone have any idea why this isn't looping right?

Anthon
  • 69,918
  • 32
  • 186
  • 246
lovefaithswing
  • 1,510
  • 1
  • 21
  • 37
  • What is the contents of `self.forms` ? – Jack M. Mar 24 '11 at 20:55
  • wow. I figured it out. I had a space/tab issue that (for some reason) wasn't throwing an error, but had it such that the stuff that appeared in the loop was actually out of it. That makes perfect sense given the behavior. It works fine now that I fixed that. – lovefaithswing Mar 24 '11 at 21:12
  • 3
    Could you please provide your comment as an answer. Now others, when searching for old, unanswered questions will find your question again. You could, and probably should, even mark that answer as accepted. – Anthon Apr 08 '13 at 09:39

0 Answers0