<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _validate_ctypes(self, from_obj, to_obj):
 """ Asserts that the content types for the given object are valid for this relationship. If validation fails, ``AssertionError`` will be raised. """

        if from_obj:
            from_ctype = ContentType.objects.get_for_model(from_obj)
            assert from_ctype.natural_key() == self.from_content_type.natural_key(), (
                'Relationship "%s" does not support connections '
                'from "%s" types' % (self.name, from_ctype))
        if to_obj:
            to_ctype = ContentType.objects.get_for_model(to_obj)
            assert to_ctype.natural_key() == self.to_content_type.natural_key(), (
                'Relationship "%s" does not support connections '
                'to "%s" types' % (self.name, to_ctype))