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:
parent
0dd07ea281
commit
946cc49a88
1 changed files with 9 additions and 0 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue