diff --git a/apptax/admin/filters.py b/apptax/admin/filters.py index e6c1e295..c490a065 100644 --- a/apptax/admin/filters.py +++ b/apptax/admin/filters.py @@ -56,7 +56,7 @@ def get_dynamic_options(self, view): class FilterBiblist(DynamicOptionsMixin, FilterEqual): def apply(self, query, value, alias=None): - return query.join(Taxref.liste).filter(Taxref.liste.any(id_liste=value)) + return query.join(Taxref.listes).filter(Taxref.listes.any(id_liste=value)) def get_dynamic_options(self, view): if has_app_context(): diff --git a/apptax/taxonomie/models.py b/apptax/taxonomie/models.py index 1d91ea9a..8b9d9b5a 100644 --- a/apptax/taxonomie/models.py +++ b/apptax/taxonomie/models.py @@ -54,7 +54,7 @@ class CorTaxonAttribut(db.Model): valeur_attribut = db.Column(db.Text, nullable=False) bib_attribut = db.relationship("BibAttributs") - taxon = db.relationship("Taxref", backref="attributs") + taxon = db.relationship("Taxref", back_populates="attributs") def __repr__(self): return self.valeur_attribut @@ -173,6 +173,12 @@ class Taxref(db.Model): foreign_keys=[cd_ref], primaryjoin="Taxref.cd_ref == Taxref.cd_ref", ) + attributs = db.relationship("CorTaxonAttribut", back_populates="taxon") + listes = db.relationship( + "BibListes", secondary=cor_nom_liste, back_populates="noms" + ) + medias = db.relationship("apptax.taxonomie.models.TMedias", back_populates="taxon") + @hybrid_property def nom_vern_or_lb_nom(self): @@ -209,7 +215,7 @@ class BibListes(db.Model): primary_key=False, ) - noms = db.relationship("Taxref", secondary=cor_nom_liste, backref="liste") + noms = db.relationship("Taxref", secondary=cor_nom_liste, back_populates="listes") regne = db.relationship("VMRegne") group2_inpn = db.relationship("VMGroup2Inpn") @@ -269,7 +275,7 @@ class TMedias(db.Model): types = db.relationship(BibTypesMedia) - taxon = db.relationship(Taxref, backref="medias") + taxon = db.relationship(Taxref, back_populates="medias") def __repr__(self): return self.titre