'Given a string like \'3-5\', return the model of ctype #3 and pk 5.
Note that in the case of ModelChoiceField, to_python is also in charge
of security, it\'s important to get the results from self.queryset.'

def to_python(self, value):

    if (not value):
        return value
    (content_type_id, object_id) = self.get_content_type_id_object_id(value)
    queryset = self.get_queryset_for_content_type(content_type_id)
    if (queryset is None):
        self.raise_invalid_choice()
    try:
        return queryset.get(pk=object_id)
    except queryset.model.DoesNotExist:
        self.raise_invalid_choice()
