#31434: Enhancement in the default __str__() function.
-------------------------------------+-------------------------------------
Reporter: Chinmoy | Owner: Chinmoy
Type: New feature | Status: closed
Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Normal | Resolution: wontfix
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 felixxm):
* status: assigned => closed
* type: Uncategorized => New feature
* resolution: => wontfix
Old description:
> The default ** __str__() ** function provides a rather impractical
> output and almost every time the developer has to change it to get the
> summary of the model. I suggest a more elaborate default __str__()
> function which outputs the field names with their datatypes(A skeletal
> schema).Maybe it could also print the complete data with the field name
> and their values?
> This is an example of what it could output.
>
> ----
>
> <QuerySet [
> <Question: (<django.db.models.fields.AutoField: id>,
> <django.db.models.fields.CharField: question_text>,
> <django.db.models.fields.DateTimeField: pub_date>) object (1)> ]>
>
> ----
New description:
The default `__str__()` function provides a rather impractical output and
almost every time the developer has to change it to get the summary of the
model. I suggest a more elaborate default `__str__()` function which
outputs the field names with their datatypes(A skeletal schema). Maybe it
could also print the complete data with the field name and their values?
This is an example of what it could output.
{{{
<QuerySet [
<Question: (<django.db.models.fields.AutoField: id>,
<django.db.models.fields.CharField: question_text>,
<django.db.models.fields.DateTimeField: pub_date>) object (1)> ]>
}}}
--
Comment:
> The default `__str__()` function provides a rather impractical output
and almost every time the developer has to change it to get the summary of
the model.
I don't agree. The current implementation is the result of consensus
reached on [https://groups.google.com/forum/#!msg/django-
developers/7Jqzwg5nt-c/hY7KtxkfooMJ the mailing list] and IMO is useful in
most of cases. You can refresh a discussion on DevelopersMailingList if
you don't agree.
--
Ticket URL: <https://code.djangoproject.com/ticket/31434#comment:1>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/068.fa81ab1ac1db5cf877c6d9fbcd62a66e%40djangoproject.com.