#4015
[auf_rh_dae.git] / src / qbe / django_qbe / utils.py
index 1fbe9da..7830cb0 100644 (file)
@@ -88,10 +88,14 @@ def qbe_models(admin_site=None, only_admin_models=False, json=False):
 
     def get_target(field):
         name = field.rel.to.__module__.split(".")[-2].lower().capitalize()
+        try:
+            t_field = field.rel.field_name
+        except:
+            t_field = field.rel.to._meta.pk.name
         target = {
             'name': name,
             'model': field.rel.to.__name__,
-            'field': field.rel.to._meta.pk.name,
+            'field': t_field,
         }
         if hasattr(field.rel, 'through') and field.rel.through is not None:
             name = field.rel.through.__module__.split(".")[-2]