Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8864213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:11:14+00:00 2026-06-14T16:11:14+00:00

I have a SQLAlchemy model like this: class Group(Base): __tablename__ = ‘groups’ id =

  • 0

I have a SQLAlchemy model like this:

class Group(Base):
    __tablename__ = 'groups'

    id = Column(Integer, primary_key = True, ca_include = True)
    name = Column(String, ca_include = True)

class User(Base):
    __tablename__ = 'users'

    id = Column(Integer, primary_key = True, ca_include = True)
    name = Column(String, ca_include = True)
    group_id = Column(Integer, ForeignKey('groups.id'), nullable = True, ca_include = True)
    group = relationship('Group', ca_include = True)

The form library I used is deform. I installed ColanderAlchemy to convert the model definition into Colander Schema automatically:

form = deform.Form(SQLAlchemyMapping(Group), use_ajax = True)

And I can do form.render() to get a empty form. But how to fill this empty form with a record?
I tried:

group = Group.get(1)
form.render(group)

But failed.
I also followed this blog but it can only convert a single record into colander’s format but no relationship would be converted.
So… is there anyway for me to convert the SQLAlchemy record into Colander record?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T16:11:15+00:00Added an answer on June 14, 2026 at 4:11 pm

    You’ll need to utilise the dictify method associated with your given SQLAlchemyMapping schema object to convert a given model instance into an appstruct acceptable for rendering your Deform form.

    So, using your example model, this is what you might do:

    schema = SQLAlchemyMapping(Group)
    form = deform.Form(schema, use_ajax=True)
    my_group = Group(id=1, name='Foobar') #or query for an instance etc
    appstruct = schema.dictify(my_group)
    form.render(appstruct)
    

    Since ColanderAlchemy is very much cutting edge at this stage, your mileage will likely vary in newer versions (the above was written for version 0.1), especially as it is being substantially rewritten to remove the need for custom columns and relationship types in version 0.2. I’ve noticed that there were issues with the the current ColanderAlchemy 0.1b6 release – especially with regards to the mapping of relationships.

    Consult the documentation at http://colanderalchemy.rtfd.org/ for details on the latest version.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The model is like this(in SQLAlchemy): Class Cell(Base): __tablename__ = cell id = Column(Integer)
I have the following models in sqlalchemy: class Magazine(db.Model): id= db.Column(db.Integer, primary_key=True) name= db.Column(db.String(50))
I've got a sqlalchemy model that is set up like this: class Entry(Base): __tablename__
I have model class CreatedMixin(object): __abstract__ = True @declared_attr def created_by(cls): return Column(Integer, ForeignKey('user.user_id',
I have this to SQLAlchemy(using the Flask SqlAlchemy) objects defined: class User(db.Model): id =
Let's consider the following table models for sqlalchemy in python. class Worker(Base): id Column(Integer,
Say I have a SqlAlchemy model something like this: from sqlalchemy.ext.declarative import declarative_base from
I have an SQLAlchemy scheme that looks roughly like this: participation = db.Table('participation', db.Column('artist_id',
How close can I get to defining a model in SQLAlchemy like: class Person(Base):
I have an SQLAlchemy model like the one below, and at first it didn't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.