def generate_traits(
        self,
        trait_data_items: list[SDKTraitData],
        persist: bool = False,
    ) -> list[Trait]:
        """
        Given a list of trait data items, validated by TraitSerializerFull, generate
        a list of TraitModel objects for the given identity.

        :param trait_data_items: list of dictionaries validated by TraitSerializerFull
        :param persist: determines whether the traits should be persisted to db
        :return: list of TraitModels
        """
        trait_models = []
        trait_models_to_persist = []

        for trait_data_item in trait_data_items:
            # exclude traits with null values
            if (trait_value := trait_data_item["trait_value"]) is None:
                continue

            trait_key = trait_data_item["trait_key"]
            trait = Trait(
                trait_key=trait_key,
                identity=self,
                **Trait.generate_trait_value_data(trait_value),
            )
            if trait_data_item.get("transient"):
                trait.transient = True
            else:
                trait_models_to_persist.append(trait)
            trait_models.append(trait)

        if persist:
            Trait.objects.bulk_create(trait_models_to_persist)

        return trait_models

        Given a list of trait data items, validated by TraitSerializerFull, generate
        a list of TraitModel objects for the given identity.

        :param trait_data_items: list of dictionaries validated by TraitSerializerFull
        :param persist: determines whether the traits should be persisted to db
        :return: list of TraitModels
        
api/environments/identities/models.py