[sqlalchemy] Automatically Adding M2M on append causing UNIQUE constraint violation

2014-08-06 Thread Cody Scott
I have an intermediate model which I am using to keep track of which labs to include since individual labs can be removed. So when you add a new intermediate model (AgendaModel) it automatically adds all of the labs. with @event.listens_for(Agenda.modules, 'append') But there is a UNIQUE

[sqlalchemy] Automatically populate Association Object Field

2014-07-04 Thread Cody Scott
I have a Many-to-Many relationship that I would like to keep track of the order. I am wondering if I can automatically populate the module_position field based on the current number of AgendaModule's for an Agenda. class AgendaModule(db.Model): __tablename__ = 'agenda_modules'