[#3327] Corriger erreur de DB dans QBE
authorPA Parent <paparent@paparent.me>
Tue, 19 Jun 2012 13:36:39 +0000 (09:36 -0400)
committerPA Parent <paparent@paparent.me>
Tue, 19 Jun 2012 13:36:39 +0000 (09:36 -0400)
src/qbe/django_qbe/forms.py

index 620696b..374bf19 100644 (file)
@@ -191,9 +191,14 @@ class BaseQueryByExampleFormSet(BaseFormSet):
                     
                     if model in self._models:
                         _field = self._models[model]._meta.get_field(field)
+                        try:
+                            _db_column = qn(_field.db_column)
+                        except:
+                            _db_column = qn(_field.attname)
+
                         join = u"%s.%s = %s.%s" \
                                % (join_model, join_field, qn(model),
-                                  qn(_field.db_column))
+                                  qn(_db_column))
                     else:
                         join = u"%s.%s = %s" \
                                % (join_model, join_field,