def get_or_create(self, um_from_user, um_to_user, message):
        """
        Get or create a Contact

        We override Django's :func:`get_or_create` because we want contact to
        be unique in a bi-directional manner.

        """
        created = False
        try:
            contact = self.get(Q(um_from_user=um_from_user, um_to_user=um_to_user) |
                               Q(um_from_user=um_to_user, um_to_user=um_from_user))

        except self.model.DoesNotExist:
            created = True
            contact = self.create(um_from_user=um_from_user,
                                  um_to_user=um_to_user,
                                  latest_message=message)

        return (contact, created)
def get_or_create ( self , um_from_user , um_to_user , message ) : created = False try : contact = self . get ( Q ( um_from_user = um_from_user , um_to_user = um_to_user ) | Q ( um_from_user = um_to_user , um_to_user = um_from_user ) ) except self . model . DoesNotExist : created = True contact = self . create ( um_from_user = um_from_user , um_to_user = um_to_user , latest_message = message ) return ( contact , created )
Get or create a Contact

        We override Django's :func:`get_or_create` because we want contact to
        be unique in a bi-directional manner.