daevaorn / djapian

High level Xapian integration for Django
Other
6 stars 3 forks source link

Field.resolve() throws TypeError on ManyToManyField #81

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When resolve() tries to perform a ", ".join() on a models.Manager.all(), it
fails as models.Manager.all() returns a list of model objects, not a list
of strings.

A simple fix, to first convert the models to strings:

--- indexer.py       2009-09-18 09:28:37.301536672 +1000
+++ indexer.py.good  2009-09-18 09:27:46.067246693 +1000
@@ -81,7 +81,7 @@
         elif is_iterable(value):
             return ", ".join(value)
         elif isinstance(value, models.Manager):
-            return ", ".join(value.all())
+            return ", ".join(map(str, value.all()))
         return None

     def extract(self, document):

Original issue reported on code.google.com by andre...@gmail.com on 17 Sep 2009 at 11:33

GoogleCodeExporter commented 9 years ago
I should mention that this is Django 1.1 under Python 2.5.4 and 
Djapian-2.2.4-py2.5.egg 

Original comment by andre...@gmail.com on 17 Sep 2009 at 11:35

GoogleCodeExporter commented 9 years ago

Original comment by daevaorn on 18 Sep 2009 at 9:17

GoogleCodeExporter commented 9 years ago
Thanks. Fixed with r287

Original comment by daevaorn on 18 Sep 2009 at 6:40