[Django] #24004: Can't use only() with latest() if x is in only() and get_latest_by

2 views
Skip to first unread message

Django

unread,
Dec 17, 2014, 5:33:38 AM12/17/14
to django-...@googlegroups.com
#24004: Can't use only() with latest() if x is in only() and get_latest_by
----------------------------------------------+--------------------
Reporter: knyghty | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
{{{
model Page(models.Model):
...
last_modified = models.Datefield(default=timezone.now)

class Meta:
get_latest_by = 'last_modified'
}}}

Suppose I want to get the date of the last modification, I might do
something like this:

{{{ Page.objects.only('last_modified').latest() }}}

But on trying it, we seem to get stuck copying something until we reach
maximum recursion depth.

I don't know if this is a bug or if it's simply not going to work, but if
it's the latter, I think it could be documented somewhere.

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

Django

unread,
Dec 17, 2014, 5:37:30 AM12/17/14
to django-...@googlegroups.com
#24004: Can't use only() with latest() if x is in only() and get_latest_by
-------------------------------------+-------------------------------------

Reporter: knyghty | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.7
(models, ORM) | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by knyghty):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Old description:

> {{{
> model Page(models.Model):
> ...
> last_modified = models.Datefield(default=timezone.now)
>
> class Meta:
> get_latest_by = 'last_modified'
> }}}
>
> Suppose I want to get the date of the last modification, I might do
> something like this:
>
> {{{ Page.objects.only('last_modified').latest() }}}
>
> But on trying it, we seem to get stuck copying something until we reach
> maximum recursion depth.
>
> I don't know if this is a bug or if it's simply not going to work, but if
> it's the latter, I think it could be documented somewhere.

New description:

{{{
model Page(models.Model):
...
last_modified = models.Datefield()

class Meta:
get_latest_by = 'last_modified'
}}}

Suppose I want to get the date of the last modification, I might do
something like this:

{{{ Page.objects.only('last_modified').latest() }}}

But on trying it, we seem to get stuck copying something until we reach
maximum recursion depth.

I don't know if this is a bug or if it's simply not going to work, but if
it's the latter, I think it could be documented somewhere.

--

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

Django

unread,
Dec 17, 2014, 5:37:53 AM12/17/14
to django-...@googlegroups.com
#24004: Can't use only() with latest() if x is in only() and get_latest_by
-------------------------------------+-------------------------------------

Reporter: knyghty | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.7
(models, ORM) | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by knyghty:

Old description:

> {{{
> model Page(models.Model):
> ...
> last_modified = models.Datefield()


>
> class Meta:
> get_latest_by = 'last_modified'
> }}}
>
> Suppose I want to get the date of the last modification, I might do
> something like this:
>
> {{{ Page.objects.only('last_modified').latest() }}}
>
> But on trying it, we seem to get stuck copying something until we reach
> maximum recursion depth.
>
> I don't know if this is a bug or if it's simply not going to work, but if
> it's the latter, I think it could be documented somewhere.

New description:

{{{
model Page(models.Model):
...
last_modified = models.DateField()

class Meta:
get_latest_by = 'last_modified'
}}}

Suppose I want to get the date of the last modification, I might do
something like this:

{{{ Page.objects.only('last_modified').latest() }}}

But on trying it, we seem to get stuck copying something until we reach
maximum recursion depth.

I don't know if this is a bug or if it's simply not going to work, but if
it's the latter, I think it could be documented somewhere.

--

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

Django

unread,
Dec 17, 2014, 5:50:08 AM12/17/14
to django-...@googlegroups.com
#24004: Can't use only() with latest() if x is in only() and get_latest_by
-------------------------------------+-------------------------------------

Reporter: knyghty | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.7
(models, ORM) | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by bmispelon):

Hi,

I can't seem to be able to reproduce the issue you're describing (I've
attached the test case I used as a patch).
Could you also show the traceback you're getting as well as the full
composition of your models (or ideally a reduced version of it that still
shows the issue).

Thanks!

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

Django

unread,
Dec 17, 2014, 6:12:25 AM12/17/14
to django-...@googlegroups.com
#24004: Can't use only() with latest() if x is in only() and get_latest_by
-------------------------------------+-------------------------------------

Reporter: knyghty | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.7
(models, ORM) | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by knyghty):

My apologies. After some experimentation, I've determined this only fails
when using django-mptt, so I'm going to take the bug to them. Please close
this.

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

Django

unread,
Dec 17, 2014, 6:26:17 AM12/17/14
to django-...@googlegroups.com
#24004: Can't use only() with latest() if x is in only() and get_latest_by
-------------------------------------+-------------------------------------
Reporter: knyghty | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 1.7
(models, ORM) | Resolution: invalid

Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by bmispelon):

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


Comment:

No worries, thanks for following up.

(For the record, you don't need special permissions to close a ticket)

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

Reply all
Reply to author
Forward
0 new messages