1

I have been using in implementation of the code found here and it works fine on my deployed server in the django-admin. The server is running from an older checkout of django (7cfe8e8fce). On my local machine, I am running the current checkout (d407164c). When trying to access that form, I get the error below and a reference to the return line:

def _get_empty_form(self, **kwargs):
    return super(ParentInstInlineFormSet, self)._get_empty_form(parent_instance=self.instance)
empty_form = property(_get_empty_form)

Error text:

'super' object has no attribute '_get_empty_form'
Request Method: GET
Request URL:    http://localhost:8000/pmc/admin/pmc_log/reportperiod/add/
Django Version: 1.6.dev20121220194515
Exception Type: AttributeError
Exception Value:    
'super' object has no attribute '_get_empty_form'
Exception Location: /software/django-pmc-daily-log/src/pmc_log/pmc_log/forms.py in _get_empty_form, line 18

Where did _get_empty_form go? And what is the best way around this?

Community
  • 1
  • 1
Justin
  • 42,475
  • 9
  • 93
  • 111

2 Answers2

2

The _ at the start of _get_empty_form is a pretty good indicator that you shouldn't rely on it being around - it looks like it got removed in favor of using the empty_form property.

Try modifying your code to call the empty_form property on the parent class.

girasquid
  • 15,121
  • 2
  • 48
  • 58
1

Instead of using the private method _get_empty_form, I used the @property decorator.

@property
def get_empty_form(self, **kwargs):
    if self.instance is not None:
        return super(ParentInstInlineFormSet, self).empty_form(parent_instance=self.instance)
Justin
  • 42,475
  • 9
  • 93
  • 111