Relacja wiele do wielu – referencje z backpopulate

class Enrollment(db.Model):
    # ...
    # RELACJA Z Enrollment DO Student
    # Atrybut w Enrollment to 'student'
    # back_populates='enrollmentsX' MÓWI, że w klasie Student jest atrybut 'enrollmentsX'
    student = relationship('Student', back_populates='enrollmentsX')
    
    # RELACJA Z Enrollment DO Course
    # Atrybut w Enrollment to 'course'
    # back_populates='enrollmentsY' MÓWI, że w klasie Course jest atrybut 'enrollmentsY'
    course = relationship('Course', back_populates='enrollmentsY') 
    
    
class Student(db.Model):
    # ...
    # RELACJA Z Student DO Enrollment
    # Atrybut w Student to 'enrollmentsX'
    # back_populates='student' MÓWI, że w klasie Enrollment jest atrybut 'student'
    enrollmentsX = relationship('Enrollment', back_populates='student')


class Course(db.Model):
    # ...
    # RELACJA Z Course DO Enrollment
    # Atrybut w Course to 'enrollmentsY'
    # back_populates='course' MÓWI, że w klasie Enrollment jest atrybut 'course'
    enrollmentsY = relationship('Enrollment', back_populates='course')
    
    
    

Więcej w https://chatgpt.com/c/7de5fec7-fab3-4c25-8e9c-6a5f9359b9f9