From 7d153932b3c8cdbce39f9e2fa647fd481a4b06a3 Mon Sep 17 00:00:00 2001 From: Ymage Date: Thu, 22 Dec 2022 22:50:01 +0100 Subject: [PATCH] Fix back_populate relationships --- powerdnsadmin/models/role.py | 4 ++-- powerdnsadmin/models/user.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/powerdnsadmin/models/role.py b/powerdnsadmin/models/role.py index a5cf530..5440f3d 100644 --- a/powerdnsadmin/models/role.py +++ b/powerdnsadmin/models/role.py @@ -5,7 +5,7 @@ class Role(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(64), index=True, unique=True) description = db.Column(db.String(128)) - users = db.relationship('User', backref='role', lazy=True) + users = db.relationship('User', back_populates='role', lazy=True) apikeys = db.relationship('ApiKey', back_populates='role', lazy=True) def __init__(self, id=None, name=None, description=None): @@ -20,4 +20,4 @@ class Role(db.Model): self.description = description def __repr__(self): - return ''.format(self.name) + return ''.format(self.name) diff --git a/powerdnsadmin/models/user.py b/powerdnsadmin/models/user.py index 1e39569..78104f6 100644 --- a/powerdnsadmin/models/user.py +++ b/powerdnsadmin/models/user.py @@ -34,6 +34,7 @@ class User(db.Model): otp_secret = db.Column(db.String(16)) confirmed = db.Column(db.SmallInteger, nullable=False, default=0) role_id = db.Column(db.Integer, db.ForeignKey('role.id')) + role = db.relationship('Role', back_populates="users", lazy=True) accounts = None def __init__(self,