#14820: Use `TextField` instead of `PositiveIntegerField` in docs and examples
for
generic relations.
------------------------------------+---------------------------------------
Reporter: mrmachine | Owner:
Status: new | Milestone: 1.3
Component: Documentation | Version: SVN
Resolution: | Keywords: generic relation
genericforeignkey object_id type textfield
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
------------------------------------+---------------------------------------
Changes (by gabrielhurley):
* needs_better_patch: 0 => 1
* stage: Unreviewed => Accepted
* milestone: => 1.3
Comment:
Being realistic, whatever ends up in the example there is going to be
copied and pasted and become the official recommendation despite whatever
is said around it.
I suppose one of my problems with recommending the use of a `TextField` is
that you're implicitly trading wider compatibility for a performance
penalty (varying by DB): `text` columns often use more memory, can be less
performant when returned by DB queries, and can have indexing woes
depending on the database configuration... the best practice performance-
wise is to use a field of the appropriate type (`CharField`,
`IntegerField`, or `PositiveIntegerField`) if you know for a fact that the
values will always be of that type.
What it all boils down to is that there isn't one right answer here.
If someone feels they have enough to say to write a whole section on best
practices for using GFK's in reusable apps I'd love to see it.
If not, then I'd rather see this patch in reverse: keep the primary
recommendation as "use a field of the appropriate type" and add a big
solid note that authors of reusable apps may want to use a `TextField` in
order to support both integer and non-integer PK's. The point is
definitely important, though; I think it could have an `admonition`
directive to call attention to it.
And in the end, I firmly believe there are more people reading this
section of the docs just trying to make their own Django app work than
there are folks trying to write reusable apps that are having bugs because
their GFK didn't support a non-integer PK.
--
Ticket URL: <http://code.djangoproject.com/ticket/14820#comment:8>
Django <http://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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.