1
0
Fork 0
mirror of https://github.com/yweber/lodel2.git synced 2025-11-14 18:09:17 +01:00

Added default values for django models Field types

This commit is contained in:
Roland Haroutiounian 2015-09-16 17:31:08 +02:00
commit 946cc49a88

View file

@ -65,6 +65,15 @@ class EmField(EmComponent):
return True
def to_django(self):
if self.fieldtype in ('varchar', 'char'):
max_length = None if 'max_length' not in self.options else self.options['max_length']
return self.fieldtypes[self.fieldtype](max_length=max_length, **self.options)
if self.fieldtype in ('time', 'datetime', 'date'):
auto_now = False if 'auto_now' not in self.options else self.options['auto_now']
auto_now_add = False if 'auto_now_add' not in self.options else self.options['auto_now_add']
return self.fieldtypes[self.fieldtype](auto_now=auto_now, auto_now_add=auto_now_add, **self.options)
if self.fieldtype == 'boolean' and ('nullable' in self.options and self.options['nullable'] == 1):
return models.NullBooleanField(**self.options)