Or, to be precise, how do I properly present a form to edit a db.ListProperty of db.Keys on a model admin page, with app-engine-patch for Django?
I have a Category
like this:
class Category(db.Model):
title = db.CategoryProperty(required=True)
and a Post
with this:
categories = db.ListProperty(db.Key)
Currently in the Django admin page the field is shown as a textbox containing the Python list object string, which is wrong and breaks saving:
[datastore_types.Key.from_path(u'blog_category', 3L, _app_id_namespace=u'xyz')]
So I've had to 'exclude' it in my ModelAdmin class. I've thought of writing a ModelForm that manually to wire up the Category db.Keys and present them as a Django multiselect widget, but I suspect there are easier ways to do it...
Having read through the App-engine-patch docs more thoroughly, seems that using ragendja.dbutils.KeyListProperty
answers this problem, with the old Django multiselection list too. :)
New code:
categories = KeyListProperty(Category)