Hello,

I have so far not found any discussion of a particular problem I
encountered. I'm not sure that isn't just me doing something
incorrectly so would appreciate knowing if anyone else has seen this.

I have a pair of models where one inherits from the other (Multi-table
inheritance). The parent model in that relationship has a ForeignKey
relation to a third model with an order_with_respect_to meta option
set to that ForeignKey.

Although I seem to be able to work with these models in the shell
(create, save, list). If I use the dumpdata management command I get
the following error.

$ ./manage.py dumpdata myapp
Traceback (most recent call last):
  File "./manage.py", line 12, in <module>
    execute_manager(settings)
  File "/home/bdp/Checkouts/django-trunk/django/core/management/
__init__.py", line 362, in execute_manager
    utility.execute()
  File "/home/bdp/Checkouts/django-trunk/django/core/management/
__init__.py", line 303, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/bdp/Checkouts/django-trunk/django/core/management/
base.py", line 195, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/bdp/Checkouts/django-trunk/django/core/management/
base.py", line 222, in execute
    output = self.handle(*args, **options)
  File "/home/bdp/Checkouts/django-trunk/django/core/management/
commands/dumpdata.py", line 76, in handle
    objects.extend(model._default_manager.all())
  File "/home/bdp/Checkouts/django-trunk/django/db/models/query.py",
line 83, in __len__
    self._result_cache.extend(list(self._iter))
  File "/home/bdp/Checkouts/django-trunk/django/db/models/query.py",
line 238, in iterator
    for row in self.query.results_iter():
  File "/home/bdp/Checkouts/django-trunk/django/db/models/sql/
query.py", line 287, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/home/bdp/Checkouts/django-trunk/django/db/models/sql/
query.py", line 2360, in execute_sql
    sql, params = self.as_sql()
  File "/home/bdp/Checkouts/django-trunk/django/db/models/sql/
query.py", line 397, in as_sql
    ordering, ordering_group_by = self.get_ordering()
  File "/home/bdp/Checkouts/django-trunk/django/db/models/sql/
query.py", line 962, in get_ordering
    self.model._meta, default_order=asc):
  File "/home/bdp/Checkouts/django-trunk/django/db/models/sql/
query.py", line 991, in find_ordering_name
    opts, alias, False)
  File "/home/bdp/Checkouts/django-trunk/django/db/models/sql/
query.py", line 1737, in setup_joins
    "Choices are: %s" % (name, ", ".join(names)))
django.core.exceptions.FieldError: Cannot resolve keyword '_order'
into field. Choices are: category, id, item_ptr, name, notes

If I comment out the order_with_respect_to meta option the message
goes away. I first encountered this error running the release version
if Django (as installed by easy_install) but I tried it with django-
trunk and got the same thing.

I simplified my models down to some basics which still cause the
problem.

class Category(models.Model):
    name = models.CharField(max_length=30, unique=True)

    class Meta:
        ordering = ['name']

class Item(models.Model):
    name = models.CharField(max_length=30, unique=True)
    category = models.ForeignKey(Category)

    class Meta:
        order_with_respect_to = 'category'

class OtherItem(Item):
    notes = models.TextField(blank=True)

Am I trying to do something that should not work? Or am I doing it the
wrong way?

Sincerely,
Bradley Peters
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to