magopian / django-data-exports

Model data exports for Django
http://django-data-exports.rtfd.org
BSD 3-Clause "New" or "Revised" License
39 stars 12 forks source link

AttributeError: 'SingleRelatedObjectDescriptor' object has no attribute 'field' #1

Closed ppo closed 11 years ago

ppo commented 12 years ago

After clicking on "Save" while creating a new export on model E (see below).

Traceback

File "virtualenv/lib/python2.6/site-packages/data_exports/forms.py", line 41, in add_fields choices = get_choices(model) >>> model = <E>

File "virtualenv/lib/python2.6/site-packages/data_exports/forms.py", line 58, in get_choices choices += get_choices(related_model, prefixes=new_prefixes) >>> model = <D>

File "virtualenv/lib/python2.6/site-packages/data_exports/forms.py", line 58, in get_choices choices += get_choices(related_model, prefixes=new_prefixes) >>> model = <C>

File "virtualenv/lib/python2.6/site-packages/data_exports/forms.py", line 58, in get_choices choices += get_choices(related_model, prefixes=new_prefixes) >>> model = <A>

File "virtualenv/lib/python2.6/site-packages/data_exports/forms.py", line 54, in get_choices related_model = getattr(model, f).field.rel.to >>> model = <A>

Classes

class A(models.Model):
  # some fields

class B(A):
  # some fields

class C(A):
  b = models.ForeignKey(B)
  # some fields

class D(A):
  b = models.ForeignKey(B)
  c = models.ForeignKey(C)
  # some fields

class E(models.Model):
  d = models.ForeignKey(D)
  b = models.ForeignKey(B)
  # some fields

Environment

Python 2.6.5 Django==1.3.1 django-data-exports==0.2 django-inspect-model==0.4

magopian commented 12 years ago

Thanks for the report, i'll look into that asap!

ppo commented 12 years ago

With Django==1.4

AttributeError: 'ExportAdmin' object has no attribute 'inline_instances'

Traceback

File "virtualenv/lib/python2.6/site-packages/django/contrib/admin/options.py", line 1063, in change_view for FormSet, inline in zip(self.get_formsets(request, obj), inline_instances): >>> obj = <E> >>> inline_instances = [<data_exports.admin.ColumnInline>]

File "virtualenv/lib/python2.6/site-packages/data_exports/admin.py", line 34, in get_formsets for inline in self.inline_instances: >>> self = <data_exports.admin.ExportAdmin>

pielgrzym commented 11 years ago

@ppo - fixed this in the pull request if you're still interested.

magopian commented 11 years ago

fixed by @pielgrzym pull request #2

ppo commented 11 years ago

Thanks, I'll give it another try :-)