django-nonrel/djangoappengine — Issue #6: Order_by does not work with foreign key fields
Author: wrwrwr
Created: 2011-12-19 20:12:55+00:00
State: open

Could someone confirm that this is actually a GAE bug or shed some more light on the issue (maybe it's not supposed to work?).

```python
# test_ob_fk/models.py

from django.db import models

class A(models.Model):
pass

class B(models.Model):
a = models.ForeignKey(A)
```

```python
# shell
from test_ob_fk.models import *
a = A(); a.save();
b = B(a=a); b.save();
B.objects.all().order_by('a')
```

Expected to see a list with a single "B" object, but got nothing. Tested with GAE 1.6.1, Python 2.7 and not so very unclean development branches.

Appengine compiler sees the ordering and passes it to GAE, which seems to process it without trouble, the query created is:
```
google.appengine.api.datastore.
Query(app='dev~app', kind='test_ob_fk_b', order=CompositeOrder([PropertyOrder()]))
```
so it should work, shouldn't it?