straight55b / app-engine-patch

Automatically exported from code.google.com/p/app-engine-patch
0 stars 0 forks source link

Can't perform admin functions on a model with choices. #212

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a model with a choice property, using a set as per the GAE docs:
class Person(db.Model): 
    name = db.StringProperty(required=True)
    gender = db.StringProperty(choices=set(["male", "female"]))

2. Register the model with the admin site:
class PersonAdmin(admin.ModelAdmin):
    list_display = ('name', 'gender')

admin.site.register(Person, PersonAdmin)

3. Log in to the admin site and attempt to administer the model; it will
raise an error in the patch code.

This is happening on OSX, patch version 1.1RC

It looks to me like there's a problem on line 180 of patch.py.
Naked choices is not in scope, and self.choices is not iterable, when using
GAE model.
It works when patched as follows:
@@ -177,7 +177,7 @@
         """Flattened version of choices tuple."""
         if not self.choices:
             return []
-        if not isinstance(choices[0], (list, tuple)):
+        if not isinstance(self.choices, (list, tuple)):
             return [(choice, choice) for choice in self.choices]
         flat = []
         for choice, value in self.choices: 

Original issue reported on code.google.com by hux...@gmail.com on 2 Sep 2009 at 1:08

GoogleCodeExporter commented 9 years ago
I see the same on Windows Vista, patch version 1.1RC.

Original comment by piet.nie...@gmail.com on 22 Nov 2009 at 9:28