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 6365949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:21:34+00:00 2026-05-25T00:21:34+00:00

The following totally incomplete snippet defines a basic SQLAlchemy relationship using declarative syntax… Base

  • 0

The following totally incomplete snippet defines a basic SQLAlchemy relationship using declarative syntax…

Base = declarative_base()
class Movie(Base):
    __tablename__ = 'movies'
    id = Column(Integer, primary_key=True)
    name = Column(String)
    director = relationship("People", uselist = False)

class People(Base):
    __tablename__ = 'people'
    id = Column(Integer, primary_key=True)
    name = Column(String, nullable = false)

To access the director name it would be something like:

assert isinstance(movie, Movie) # <-- retrieved with query or whatever
director_name = movie.director.name

If, for convenience, I always want the director relationship to just give me the director’s name, rather than a People instance, how do you do this? eg: it should work just like this:

assert isinstance(movie, Movie)
director_name = movie.director  # <-- should get the string directly

I’m 99% sure I’ve done this before but can’t find any reference code or documentation on it anymore. I’m going a bit crazy trying to locate it. Stack Overflow will be a good/permanent reference location for the answer.

  • 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-05-25T00:21:35+00:00Added an answer on May 25, 2026 at 12:21 am

    The association proxy is used for all kinds of “object reference-> attribute reference” styles of transformation on the Python side. Docs have been newly updated and rewritten:

    http://www.sqlalchemy.org/docs/orm/extensions/associationproxy.html

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

Sidebar

Related Questions

I´m totally new to programming in java, and following some basic tutorials for my
I'm totally new to WPF. The following code snippet has the style/settings for a
i have the following Problem - first of all i'm totally new to Flex.
I have the following problem. My J2ME app goes totally dead. I though it
Check the following link in Chrome: http://www.bavarianblue.com/parts-list/?tags=struts The site is totally jacked in IE
I have the following class in PHP class MyClass { // How to declare
Following on from this question , I'm totally stumped on getting LaTeX to give
In following lines i do understand LINQ part but then i get totally numb
I am totally new to Android, and I am following this tutorial . My
I am absolutely totally news to Rails and to MongoDB. I have been following

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.