Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Use a callable instead, e.g., use `dict` instead of `{}`

# You have two options here:

# 1.Rely on dict as a default; this will result in your models using an empty dict {} if none is supplied:
class UnderwritingValidator(TimeStampedModel):
    plan = models.PositiveIntegerField(null=True, blank=True, unique=True)
    logic = JSONField(default=dict)

# 2.Create your own "callable" and use it as default:
def get_default_something():
    return {'accept_list': [], 'reject_list': []}

class UnderwritingValidator(TimeStampedModel):
    plan = models.PositiveIntegerField(null=True, blank=True, unique=True)
    logic = JSONField(default=get_default_something)
Comment

PREVIOUS NEXT
Code Example
Python :: sphinx autodoc command 
Python :: command line arguments in python debugging 
Python :: python merge strings 
Python :: add icon to exe file 
Python :: python terminal progress bar 
Python :: how to count substring in a string in python 
Python :: python removing duplicate item 
Python :: nested ternary operator python 
Python :: how to make a key logger 
Python :: python for unity 
Python :: run python script on remote server 
Python :: #remove a sublist from a list-use remove method 
Python :: ImportError: No module named _bootlocale 
Python :: keyboard write python 
Python :: function to remove punctuation in python 
Python :: python os.remove permissionerror winerror 5 access is denied 
Python :: super title python 
Python :: messages in django 
Python :: create requirements file and load it in new envirnment. 
Python :: beautifulsoup get h1 
Python :: if and else in python 
Python :: tkinter stringvar not working 
Python :: django background_task 
Python :: changing names of column pandas 
Python :: session in django 
Python :: isnumeric() in python 
Python :: print format python 
Python :: how to concatenate in python 
Python :: print function args python 
Python :: python even or odd 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =