An Address is a built-in class in docassemble. So, you have to state in the YAML file that you are using the Address object.

objects: 
  address: Address

Text Attributes

The Address object has several text attributes, which you ask for under fields:

attribute example
address “123 Main Street”
unit “Suite 100”
city “Springfield”
state “MA”
zip (or postal_code) “01199”
country “US”

You can provide the user with a list of states:

fields:
  - State: address.state
    code: |
      states_list()
    required: False

You can provide the user with a list of countries:

fields:
  - Country: address.country
    code: |
      countries_list()
    required: False

Return Address in Mako

The following example shows several ways you can return the address in Mako.

mandatory: True
question: Your address
subquestion: |
  ### Address Block 
  
  Default:
  
  ${ address }
  
  Showing the country:
  
  ${ address.block(show_country=True) }
  
  International:
  
  ${ address.block(international=True) }
  
  ### State 
  
  You live in
  ${ state_name(address.state) },
  which is abbreviated
  ${ address.state }.

Use the .block() method to return a formatted address.

Additional Resources

See

[Updated 10/1/2020]