[Django] #21414: Remove django.db.models.related.RelatedObject

33 views
Skip to first unread message

Django

unread,
Nov 9, 2013, 12:04:46 PM11/9/13
to django-...@googlegroups.com
#21414: Remove django.db.models.related.RelatedObject
----------------------------------------------+--------------------
Reporter: akaariai | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Database layer (models, ORM) | Version: 1.6
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
Currently related fields have two similar attributes, self.rel and
self.related. The first is ForeignObjectRel subclass, the second is
RelatedObject. Both of these do almost the same thing, and it doesn't seem
necessary to have both rel and related. It is confusing to try to remember
which one does what.

In the proposed patch at
https://github.com/akaariai/django/tree/related_rel_removal the
RelatedObject usage is removed. The idea is to make ForeignObjectRel to
work exactly like RelatedObject worked and provide the same instance from
field.rel and field.related.

I've opted for deprecation path where RelatedObject can still be used, and
so can field.related, too. The field.related attribute is actually
ForeignObjectRel, but by usage of `__instancecheck__`
isinstance(field.related, RelatedObject) answers yes. This should make
this change easy for 3rd party apps.

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

Django

unread,
Nov 10, 2013, 3:57:44 AM11/10/13
to django-...@googlegroups.com
#21414: Remove django.db.models.related.RelatedObject
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 1
Keywords: | Patch needs improvement: 1
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by loic84):

* cc: loic@… (added)
* needs_better_patch: => 1
* needs_tests: => 0
* version: 1.6 => master
* needs_docs: => 1
* has_patch: 0 => 1
* stage: Unreviewed => Accepted


Comment:

Looking pretty good.

I left a couple of comments on commit
[https://github.com/akaariai/django/commit/8d63a8efb21c5f08f0a0beb1200eaa78017f52e0
8d63a8e] (linking to it since these are lost on rebase).

Dunno if it's an omission or still on the todo list, but it's missing the
deprecation docs.

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

Django

unread,
Nov 10, 2013, 4:53:24 AM11/10/13
to django-...@googlegroups.com
#21414: Remove django.db.models.related.RelatedObject
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody

Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 1
Keywords: | Patch needs improvement: 1
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by akaariai):

I am no sure about docs. This is completely private API...

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

Django

unread,
Nov 10, 2013, 4:59:25 AM11/10/13
to django-...@googlegroups.com
#21414: Remove django.db.models.related.RelatedObject
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody

Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 1
Keywords: | Patch needs improvement: 1
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by loic84):

By docs I meant `docs/internals/deprecation.txt`, dunno if this document
is meant for public consumption or for internal housekeeping.

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

Django

unread,
Nov 10, 2013, 7:27:08 AM11/10/13
to django-...@googlegroups.com
#21414: Remove django.db.models.related.RelatedObject
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody

Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 1
Keywords: | Patch needs improvement: 1
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by aaugustin):

It's only for public APIs.

If we know that a private API is used in the wild, we might mention it
there, but that's an exception.

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

Django

unread,
Nov 10, 2013, 9:50:48 AM11/10/13
to django-...@googlegroups.com
#21414: Remove django.db.models.related.RelatedObject
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody

Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0

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

* needs_docs: 1 => 0


Comment:

All good, I wrongly assumed it was a TODO list for when the new dev branch
is created.

So yes, it's not needed here since this is very much private APIs.

--
Ticket URL: <https://code.djangoproject.com/ticket/21414#comment:5>

Django

unread,
Dec 12, 2014, 5:44:46 PM12/12/14
to django-...@googlegroups.com
#21414: Remove django.db.models.related.RelatedObject
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody

Type: | Status: new
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: | Patch needs improvement: 1
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by timgraham):

Anssi, do you think there is much work to do to incorporate this in 1.8?
Might it simply the `_meta` refactor or should we try to merge that branch
first?

--
Ticket URL: <https://code.djangoproject.com/ticket/21414#comment:6>

Django

unread,
Dec 18, 2014, 12:36:24 PM12/18/14
to django-...@googlegroups.com
#21414: Remove django.db.models.related.RelatedObject
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: timgraham
Type: | Status: assigned

Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: | Patch needs improvement: 1
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timgraham):

* owner: nobody => timgraham
* status: new => assigned


Comment:

I'm trying to update this to apply cleanly.

--
Ticket URL: <https://code.djangoproject.com/ticket/21414#comment:7>

Django

unread,
Dec 18, 2014, 3:43:30 PM12/18/14
to django-...@googlegroups.com
#21414: Remove django.db.models.related.RelatedObject
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: timgraham
Type: | Status: assigned
Cleanup/optimization | Version: master
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: | Patch needs improvement: 0

Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: 1 => 0


Comment:

[https://github.com/django/django/pull/3757 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/21414#comment:8>

Django

unread,
Dec 23, 2014, 10:55:01 AM12/23/14
to django-...@googlegroups.com
#21414: Remove django.db.models.related.RelatedObject
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: timgraham
Type: | Status: closed
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

In [changeset:"f233bf47dde1d481108142c8d6b4bb3b3d8c6d08"]:
{{{
#!CommitTicketReference repository=""
revision="f233bf47dde1d481108142c8d6b4bb3b3d8c6d08"
Fixed #21414 -- Removed RelatedObject and deprecated Field.related.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21414#comment:9>

Django

unread,
Dec 30, 2014, 6:43:08 PM12/30/14
to django-...@googlegroups.com
#21414: Remove django.db.models.related.RelatedObject
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: timgraham
Type: | Status: closed
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by phoebebright):

Found two apps failing as they are using RelatedObject, django-taggit and
django-import-export.
To fix, would I be right in thinking it is a case of replacing

from django.db.models.fields.related import ForeignObjectRel
with
from django.db.models.related import RelatedObject

and all instances of RelatedObject with ForeignObjectRel
?

--
Ticket URL: <https://code.djangoproject.com/ticket/21414#comment:10>

Django

unread,
Dec 31, 2014, 8:32:08 AM12/31/14
to django-...@googlegroups.com
#21414: Remove django.db.models.related.RelatedObject
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: timgraham
Type: | Status: closed
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by timgraham):

Yes

--
Ticket URL: <https://code.djangoproject.com/ticket/21414#comment:11>

Django

unread,
Sep 23, 2015, 7:54:48 PM9/23/15
to django-...@googlegroups.com
#21414: Remove django.db.models.related.RelatedObject
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: timgraham
Type: | Status: closed
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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

In [changeset:"96317ad8defa89a9a4e8ecf4e22e64cb0c3054d7" 96317ad8]:
{{{
#!CommitTicketReference repository=""
revision="96317ad8defa89a9a4e8ecf4e22e64cb0c3054d7"
Refs #21414 -- Removed Field.related per deprecation timeline.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21414#comment:12>

Reply all
Reply to author
Forward
0 new messages