Suppose I had this following code:
class MyModel(models.Model): ... ... def save(self, *args, **kwargs): # pre-save edits can go here... super(MyModel, self).save(*args, **kwargs) When I create and save a model, MyModel(blah, blah, blah), there is a possibility that one of the input fields is "None". In the overridden save method, the goal is to check for if a field is none, and if one is, change it to some other default value.
Are the input fields in args or kwargs? And is overriding save() even the proper way to do this?
I was thinking something like this:
def save(self, *args, **kwargs): if 'username' in args and args['username'] is None: args['username'] = some_default_value super(MyModel, self).save(*args, **kwargs) So where are the input params? args* or **kwargs, thank you.