#20113: Documentation on _ptr and _ptr_id use in multi-table inheritance
-------------------------------------+-------------------------------------
Reporter: anonymous | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: 1.5
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):
* component: Uncategorized => Documentation
* type: Uncategorized => Cleanup/optimization
Old 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".
New 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".
--
--
Ticket URL: <https://code.djangoproject.com/ticket/20113#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.727f554af3081b34479d1dc9366bc7a4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.