Re: Inline Form Error After Upgrade to Django 1.3
Awesome, that was it. My old code now works again. Thanks! Chris On Mon, Apr 18, 2011 at 5:47 PM, akaariaiwrote: > On Apr 19, 12:17 am, Chris Spencer wrote: > > 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' > > Doh, that should of course be ._state. Sorry for the mistake. > > - Anssi > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > 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 django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Inline Form Error After Upgrade to Django 1.3
On Apr 19, 12:17 am, Chris Spencerwrote: > 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' Doh, that should of course be ._state. Sorry for the mistake. - Anssi -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Inline Form Error After Upgrade to Django 1.3
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, akaariaiwrote: > On Apr 18, 11:08 pm, Chris 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 django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > 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 django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Inline Form Error After Upgrade to Django 1.3
On Apr 18, 11:08 pm, Chriswrote: > 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 django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Inline Form Error After Upgrade to Django 1.3
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? Regards, Chris -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.