I had to use OpenCode to try and help with the list:reference issue using a test app. The workaround does seem to work.
cat models.py
─────┬─────────────────────────────────────────────────────────────────────────────────────────────────
│ File: models.py
─────┼─────────────────────────────────────────────────────────────────────────────────────────────────
1 │ """
2 │ This file defines the database models
3 │ """
4 │
5 │ from pydal.validators import *
6 │
7 │ from .common import Field, db
8 │
9 │ db.define_table("cars",
10 │ Field("car_make", "string", help="Car Make & Model",
11 │ required=True, unique=True,
12 │ format="%(car_make)s")
13 │ )
14 │
15 │ db.define_table("owner",
16 │ Field("owner_name", "string", required=True),
17 │ Field("cars", "list:reference cars", multiple=True)
18 │ )
19 │
20 │
21 │ # --- Workaround: make "cars" display as a list of car names ---
22 │ # This pydal version does not derive <table>._format from a field's format,
23 │ # and list:reference fields do not get a default represent/validator here.
24 │ # Set them explicitly so Grids and Forms render a list of cars instead of ids.
25 │ db.cars._format = lambda r: r.get("car_make") or
r.id 26 │ db.owner.cars.requires = IS_IN_DB(db, "
cars.id", db.cars._format, multiple=True)
27 │ db.owner.cars.represent = (
28 │ lambda value, row=None: ", ".join(
29 │ db.cars._format(db.cars(v)) for v in (value or [])
30 │ )
31 │ if value
32 │ else ""
33 │ )
34 │
35 │ db.commit()
36 │