----
<QuerySet [
<Question: (<django.db.models.fields.AutoField: id>,
<django.db.models.fields.CharField: question_text>,
<django.db.models.fields.DateTimeField: pub_date>) object (1)> ]>
----
--
Ticket URL: <https://code.djangoproject.com/ticket/31434>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* Attachment "modelpreview.png" added.
An example screenshot of the str() output
* 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>