class ParentClass(meta.Model):
somevar = meta.CharField(maxlength=100)
def __repr__(self):
return self.somevar
class META:
admin = meta.Admin()
ordering = ['somevar']
class FirstChild(meta.Model):
theparent = meta.ForeignKey(ParentClass)
myvar = meta.CharField(maxlength=100)
def __repr__(self):
return self.myvar
class META:
admin = meta.Admin()
order_with_respect_to = 'theparent'
I can add ParentClass- and FirstChild-Items in Admin and viewing the
ParentClass-List works, too. Viewing the FirstChild-List, however,
results in an error:
There's been an error:
Traceback (most recent call last):
File
"C:\Programme\Python24\lib\site-packages\django\core\handlers\base.py",
line 64, in get_response
response = callback(request, **param_dict)
File
"C:\Programme\Python24\lib\site-packages\django\views\admin\main.py",
line 132, in change_list
if isinstance(lookup_opts.get_field(order_field).rel,
meta.ManyToOne):
File
"C:\Programme\Python24\lib\site-packages\django\core\meta\__init__.py",
line 252, in get_field
raise FieldDoesNotExist, "name=%s" % name
FieldDoesNotExist: name=_order
Any ideas how I can get that to work?
Andreas
thanks, it's good to know that I'm not going to find the bug in my
code.
While trying different things, I too found out that adding the
"ordering"-option made the listview work again. The first thing I tried
was adding ordering = ['theparent']:
class FirstChild(meta.Model):
...
class META:
admin = meta.Admin(ordering = ['theparent'])
The resulting Admin view was a table in which every entry appeared
three times instead of once. Is this a related bug, something different
or is "ordering" by foreign keys not supported?
Andreas