diff --git a/graphene_django_cud/mutations/core.py b/graphene_django_cud/mutations/core.py index c27444f..ed57917 100644 --- a/graphene_django_cud/mutations/core.py +++ b/graphene_django_cud/mutations/core.py @@ -252,6 +252,10 @@ def upsert_obj( Model, ) + @classmethod + def before_create_obj(cls, info, input, obj): + return None + @classmethod def create_obj( cls, @@ -378,7 +382,7 @@ def create_obj( model_field_values[name + "_id"] = obj_id # Foreign keys are added, we are ready to create our object - obj = Model.objects.create(**model_field_values) + obj = Model(**model_field_values) # Handle one to one rels if len(one_to_one_rels) > 0: @@ -408,7 +412,10 @@ def create_obj( setattr(obj, name, new_value) - obj.save() + + cls.before_create_obj(info, input, obj) + + obj.save() # Handle extras fields for name, extras in many_to_many_extras.items():