I don't think you should need `to_deprecated_string` here - it's not used in L174 (sorry I just noticed this in my final pass-through).

I also wonder if it would work in the initial call to instead do `StudentModule.objects.get_or_create` and supply default for `state`, this is done many places for example https://github.com/edx/edx-platform/blob/master/lms/djangoapps/courseware/model_data.py#L242