Opened 2 years ago

Closed 2 years ago

#20113 closed Uncategorized (duplicate)

Documentation on _ptr and _ptr_id use in multi-table inheritance

Reported by: anonymous Owned by: nobody
Component: Uncategorized Version: 1.5
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The documentation on "Multi-table inheritance" does not mention the naming of the (generated) primary / foreign key field of the inheriting table (which becomes place_ptr_id in the Place / Restaurant example).

If I use instance data from that model in a template, and want to render the fields myself, I need that name, as described in "Using the formset in the template":

<form method="post" action="">

{{ formset.management_form }}
{% for form in formset %}

{{ form.place_ptr }}
<ul>

<li>{{ ... }}</li>

</ul>

{% endfor %}

</form>

Confusingly, the name which should be used here is "place_ptr", not "place_ptr_id", which it is in the database (using "place_ptr_id" in the template gives a MultiValueDictKeyError). Since this is not documented (or I haven't found it, though I did search!), I suggest adding something to the "Multi-table inheritance" documentation which explains how the auto-generated field can be used in templates as "place_ptr".

Change History (2)

comment:1 Changed 2 years ago by marc@…

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 2 years ago by timo

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #11097

Note: See TracTickets for help on using tickets.
Back to Top