def _map_table_name ( self , model_names ) : for model in model_names : if isinstance ( model , tuple ) : model = model [ 0 ] try : model_cls = getattr ( self . models , model ) self . table_to_class [ class_mapper ( model_cls ) . tables [ 0 ] . name ] = model except AttributeError : pass
python dynamically make data go from one table to another
Pre foregin_keys potrbejeme pre z nazvu tabulky zistit class tak si to namapujme
def _map_table_name(self, model_names):
        """
        Pre foregin_keys potrbejeme pre z nazvu tabulky zistit class,
        tak si to namapujme
        """

        for model in model_names:
            if isinstance(model, tuple):
                model = model[0]

            try:
                model_cls = getattr(self.models, model)
                self.table_to_class[class_mapper(model_cls).tables[0].name] = model
            except AttributeError:
                pass