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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:36:28+00:00 2026-05-27T22:36:28+00:00

db.define_table(‘person’, Field(‘name’), format=’%(name)s’) What does this format do here?

  • 0

db.define_table(‘person’, Field(‘name’), format=’%(name)s’)

What does this format do here?

  • 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-27T22:36:29+00:00Added an answer on May 27, 2026 at 10:36 pm

    The format argument is used to determine how fields in other tables that reference the ‘person’ table will be displayed. For example, if you define:

    db.define_table('dog',
        Field('name'),
        Field('owner', db.person)
    

    The ‘owner’ field is a reference field that references the ‘person’ table (i.e., it stores record id’s of records from the ‘person’ table). In most cases, when you display data from the ‘dog’ table, you don’t want to display the raw db.person record id that is stored in the ‘owner’ field because that doesn’t have any meaning — instead, it makes more sense to display the ‘name’ of the person. In web2py, the format attribute of the table enables this automatic substitution in both forms and tables.

    When you create a SQLFORM based on the ‘dog’ table, it will automatically generate a drop-down list for the ‘owner’ field, and because of the format='%(name)s' argument to the ‘person’ table definition, the drop-down list will display db.person names instead of record id’s (even though upon form submission, the ‘owner’ field will store the associated record id rather than the name).

    Also, if you display records from the ‘dog’ table in a SQLTABLE or SQLFORM.grid, the ‘owner’ field will show the owner’s name rather than the owner’s record id.

    See http://web2py.com/books/default/chapter/29/6#Record-representation.

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

Sidebar

Related Questions

I have this model in web2py DAL: db.define_table('category', Field('name','string'), format='%(name)s' ) db.define_table('uploaded_question', Field('text','string'), ...
I have a table defined in web2py db.define_table( 'pairing', Field('user',writable=True,readable=True), Field('uid', writable=True , readable=True)
I'm using custom radiobuttons with a SQLFORM as shown below: def radioboxes(field,value): items=[DIV(name,INPUT(_type='radio',_value=key,_name=field.name,value=value), _class='radio')
if i define a table like this: Dim datatable As PdfPTable = New PdfPTable(4)
When I'm setting up a MySQL table, it asks me to define the name
Does anyone know its its possible to define a table once in a .feature
This is the first time I am working for a front-end project that requires
This is probably a simple question, I have a form that you put in
I have pretty much the same question as stated here: Set listener for store
i'm trying to figure this out for days and i can't find what the

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.