django-nonrel/djangoappengine — pull request #10 by aburgel (2011-12-27 22:24:26+00:00)
Title: Ancestor queries and GAEKey

this is a cleaned up pull request that i originally submitted on bitbucket:

https://bitbucket.org/wkornewald/djangoappengine/pull-request/10/gaekeyfield-and-ancestor-queries

i've been using it for about a month now on a project (not yet in production). its been working quite well. i would love some feedback on the syntax and naming.

some examples on how to use it, to create a model with an ancestor-able key:

```python
from djangoappengine import fields as gaefields

class Model(models.Model):
key = gaefields.GAEKeyField(primary_key=True, parent_key_name='parent_key')
```

to set a parent key:

```python
parent = Model()
parent.save()

child = Model(parent_key=parent.key)
child.save()
```

an ancestor query:

```python
from djangoappengine.models import GAEKey

parent_key = GAEKey(id_or_name='1234')
Model.objects.filter(key=parent_key.as_ancestor())
```