[Django] #28266: from_db example in instance.txt doesn't work

32 views
Skip to first unread message

Django

unread,
Jun 1, 2017, 9:28:52 PM6/1/17
to django-...@googlegroups.com
#28266: from_db example in instance.txt doesn't work
--------------------------------------------+------------------------
Reporter: Lachlan Musicman | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
--------------------------------------------+------------------------
I think it's because of a mislabelling. Note that a new cls is created and
it's called new. After that it's referred to as instance.

{{{
@classmethod
def from_db(cls, db, field_names, values):
# Default implementation of from_db() (subject to change and could
# be replaced with super()).
if len(values) != len(cls._meta.concrete_fields):
values = list(values)
values.reverse()
values = [
values.pop() if f.attname in field_names else DEFERRED
for f in cls._meta.concrete_fields
]
new = cls(*values)
instance._state.adding = False
instance._state.db = db
# customization to store the original field values on the instance
instance._loaded_values = dict(zip(field_names, values))
return instance
}}}

Should be

{{{
instance = cls(*values)
instance._state.adding = False
instance._state.db = db
# customization to store the original field values on the instance
instance._loaded_values = dict(zip(field_names, values))
return instance
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28266>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 1, 2017, 9:29:10 PM6/1/17
to django-...@googlegroups.com
#28266: from_db example in instance.txt doesn't work
----------------------------------+--------------------------------------

Reporter: Lachlan Musicman | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by Lachlan Musicman):

* Attachment "16df9cb6cc6188a53de32bbdcbb25fba54d83aa5.patch" added.

Patch file

Django

unread,
Jun 2, 2017, 9:16:36 AM6/2/17
to django-...@googlegroups.com
#28266: Typo in docs/ref/models/instances.txt Model.from_db() code example
-------------------------------------+-------------------------------------

Reporter: Lachlan Musicman | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* type: Uncategorized => Bug
* stage: Unreviewed => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/28266#comment:1>

Django

unread,
Jun 2, 2017, 9:17:34 AM6/2/17
to django-...@googlegroups.com
#28266: Typo in docs/ref/models/instances.txt Model.from_db() code example
-------------------------------------+-------------------------------------
Reporter: Lachlan Musicman | Owner: nobody
Type: Bug | Status: closed
Component: Documentation | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"00093daec9cc61d8af7fcebdbe58e263bea935a3" 00093da]:
{{{
#!CommitTicketReference repository=""
revision="00093daec9cc61d8af7fcebdbe58e263bea935a3"
Fixed #28266 -- Fixed typo in docs/ref/models/instances.txt.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28266#comment:2>

Django

unread,
Jun 2, 2017, 9:17:52 AM6/2/17
to django-...@googlegroups.com
#28266: Typo in docs/ref/models/instances.txt Model.from_db() code example
-------------------------------------+-------------------------------------
Reporter: Lachlan Musicman | Owner: nobody
Type: Bug | Status: closed
Component: Documentation | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"84dac491d4cf1901fe22c4035c8609a36f5c2c9a" 84dac491]:
{{{
#!CommitTicketReference repository=""
revision="84dac491d4cf1901fe22c4035c8609a36f5c2c9a"
[1.11.x] Fixed #28266 -- Fixed typo in docs/ref/models/instances.txt.

Backport of 00093daec9cc61d8af7fcebdbe58e263bea935a3 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28266#comment:3>

Django

unread,
Jun 2, 2017, 9:18:00 AM6/2/17
to django-...@googlegroups.com
#28266: Typo in docs/ref/models/instances.txt Model.from_db() code example
-------------------------------------+-------------------------------------
Reporter: Lachlan Musicman | Owner: nobody
Type: Bug | Status: closed
Component: Documentation | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"7b2d4a95dcd697da7bcf6ab9d3146fdac2e4d81b" 7b2d4a95]:
{{{
#!CommitTicketReference repository=""
revision="7b2d4a95dcd697da7bcf6ab9d3146fdac2e4d81b"
[1.10.x] Fixed #28266 -- Fixed typo in docs/ref/models/instances.txt.

Backport of 00093daec9cc61d8af7fcebdbe58e263bea935a3 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28266#comment:4>

Reply all
Reply to author
Forward
0 new messages