def validate_extra(self, value): # Update basket extra instead of replacing it, remove null values. extra = self.instance.extra if self.instance else {} if value: extra.update(value) extra = {k: v for k, v in extra.items() if v is not None} # Validate using extra validator. return app_settings.SALESMAN_EXTRA_VALIDATOR(extra, context=self.context)
def validate_extra(self, value): context = self.context.copy() context['basket_item'] = self.instance return app_settings.SALESMAN_EXTRA_VALIDATOR(value, context=context)