async def create_or_get(self, model_, **kwargs):
        """Try to create new object with specified data. If object already
        exists, then try to get it by unique fields.
        """
        try:
            return (await self.create(model_, **kwargs)), True
        except IntegrityErrors:
            query = []
            for field_name, value in kwargs.items():
                field = getattr(model_, field_name)
                if field.unique or field.primary_key:
                    query.append(field == value)
            return (await self.get(model_, *query)), False
async def create_or_get ( self , model_ , ** kwargs ) : try : return ( await self . create ( model_ , ** kwargs ) ) , True except IntegrityErrors : query = [ ] for field_name , value in kwargs . items ( ) : field = getattr ( model_ , field_name ) if field . unique or field . primary_key : query . append ( field == value ) return ( await self . get ( model_ , * query ) ) , False
Try to create new object with specified data. If object already
        exists, then try to get it by unique fields.