Thanks. However, changing the line to:
if not self.instance.state.adding:
results in essentially the same error:
AttributeError: 'MyModel' object has no attribute 'state'
On Mon, Apr 18, 2011 at 4:48 PM, akaariai <[email protected]> wrote:
> On Apr 18, 11:08 pm, Chris <[email protected]> wrote:
> > I have an inline form used in my admin that looks up the value for the
> > associated model, and dynamically selects the form field widget that's
> > appropriate for the data. The class looks like:
> >
> > class MyModelInlineForm(ModelForm):
> > attribute_model = ModelChoiceField(queryset=None)
> > def __init__(self,*args,**kwargs):
> > ...do stuff...
> >
> > if not self.instance._adding:
> > attribute = self.instance.attribute_model
> > self.fields['value'] =
> > get_form_field_for_attribute(attribute, self.instance)
> >
> > However, after upgrading to Django 1.3 from 1.2.3, viewing any admin
> > pages using this form throws the exception:
> >
> > AttributeError: 'MyModel' object has no attribute '_adding'
> >
> > I can't find any documentation on the instance._adding attribute, or
> > how it would have changed since 1.2.3. I've been digging through the
> > code, but I'm quite stuck. How do I resolve this?
>
> If I am not mistaken this attribute has been moved: instance._adding -
> > instance.state.adding. See django/db/models/base.py ModelState class
> and Model.__init__ method.
>
> - Anssi
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.