Browse Source

EmType: Empty foreign key should be None

ArnAud 9 years ago
parent
commit
44cd259a80
1 changed files with 4 additions and 4 deletions
  1. 4
    4
      EditorialModel/fields.py

+ 4
- 4
EditorialModel/fields.py View File

@@ -81,8 +81,8 @@ class EmField(EmComponent):
81 81
         self.optional = True if row.optional == 1 else False;
82 82
         self.internal = True if row.internal == 1 else False;
83 83
         self.icon = row.icon
84
-        self.rel_to_type_id = EditorialModel.fieldtypes.EmFieldType(int(row.rel_to_type_id)) if row.rel_to_type_id else ''
85
-        self.rel_field_id = EmField(int(row.rel_field_id)) if row.rel_field_id else ''
84
+        self.rel_to_type_id = EditorialModel.fieldtypes.EmFieldType(int(row.rel_to_type_id)) if row.rel_to_type_id else None
85
+        self.rel_field_id = EmField(int(row.rel_field_id)) if row.rel_field_id else None
86 86
 
87 87
     def save(self):
88 88
         # should not be here, but cannot see how to do this
@@ -95,8 +95,8 @@ class EmField(EmComponent):
95 95
             'optional' : 1 if self.optional else 0,
96 96
             'internal' : 1 if self.internal else 0,
97 97
             'icon' : self.icon,
98
-            'rel_to_type_id' : self.rel_to_type_id,
99
-            'rel_field_id' : self.rel_field_id
98
+            'rel_to_type_id' : self.rel_to_type_id.id if self.rel_to_type_id is not None else None,
99
+            'rel_field_id' : self.rel_field_id.id if self.rel_field_id is not None else None
100 100
         }
101 101
 
102 102
         return super(EmField, self).save(values)

Loading…
Cancel
Save