Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing renderer for ManyToMany field is not possible #57

Open
tahajahangir opened this issue Apr 18, 2014 · 0 comments
Open

Changing renderer for ManyToMany field is not possible #57

tahajahangir opened this issue Apr 18, 2014 · 0 comments

Comments

@tahajahangir
Copy link
Contributor

For simple fields, we can use Column.info for attaching FA-related metdata to columns. For ManyToOne fields, we can change info for related ForeignKey column. But for ManyToMany fields, there is not a simple way.

Suppose this schema: (simple ManyToMany relation)

class Item(Base):
    __tablename__ = 'items'
    id = Column(Integer, primary_key=True)
    name = Column(Unicode(255))

model_items_table = Table('model_items', Base.metadata,
                          Column('item_id', Integer, ForeignKey(Item.id), primary_key=True),
                          Column('model_id', Integer, ForeignKey('models.id'), primary_key=True))

class MyModel(Base):
    __tablename__ = 'models'
    id = Column(Integer, primary_key=True)
    name = Column(Unicode(255))
    many_to_many = relationship(Item, secondary=model_items_table)

We want to change ManyToMany renderer by adding info={'renderer: ...} keyword argument for a Column, but which Column?

The right Column should be one of columns in intermediate table(model_items), but adding this doesn't work for either of those two columns.

Default implementation of AttributeField.info() only checks info attribute of Item.id which is not sufficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant