Correct link to _ prefix on row page, closes #1525

This commit is contained in:
Simon Willison 2021-11-29 22:34:31 -08:00
commit a37ee74891
3 changed files with 38 additions and 2 deletions

View file

@ -1120,5 +1120,13 @@ class RowView(RowTableShared):
count = (
foreign_table_counts.get((fk["other_table"], fk["other_column"])) or 0
)
foreign_key_tables.append({**fk, **{"count": count}})
key = fk["other_column"]
if key.startswith("_"):
key += "__exact"
link = "{}?{}={}".format(
self.ds.urls.table(database, fk["other_table"]),
key,
",".join(pk_values),
)
foreign_key_tables.append({**fk, **{"count": count, "link": link}})
return foreign_key_tables