Bladeren bron

EmType: Empty foreign key should be None

ArnAud 9 jaren geleden
bovenliggende
commit
44cd259a80
1 gewijzigde bestanden met toevoegingen van 4 en 4 verwijderingen
  1. 4
    4
      EditorialModel/fields.py

+ 4
- 4
EditorialModel/fields.py Bestand weergeven

81
         self.optional = True if row.optional == 1 else False;
81
         self.optional = True if row.optional == 1 else False;
82
         self.internal = True if row.internal == 1 else False;
82
         self.internal = True if row.internal == 1 else False;
83
         self.icon = row.icon
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
     def save(self):
87
     def save(self):
88
         # should not be here, but cannot see how to do this
88
         # should not be here, but cannot see how to do this
95
             'optional' : 1 if self.optional else 0,
95
             'optional' : 1 if self.optional else 0,
96
             'internal' : 1 if self.internal else 0,
96
             'internal' : 1 if self.internal else 0,
97
             'icon' : self.icon,
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
         return super(EmField, self).save(values)
102
         return super(EmField, self).save(values)

Loading…
Annuleren
Opslaan