question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PageQuerySet.specific docs should mention filtering/ordering restrictions

See original GitHub issue

As suggested at https://stackoverflow.com/a/55532616/1853523, the docs for PageQuerySet.specific should:

  • go into more detail about the sequence of queries that happens internally
  • explain that adding specific() to a queryset expression does not make fields from the specific page available for use within filter / order_by clauses
  • mention that if your query is targetting one Page subclass in particular, you can work around this by reorganising your query to not require specific, e.g. article_index_page.get_children().specific() becomes ArticlePage.objects.child_of(article_index_page)
  • possibly also mention that the above workaround won’t help you if you have multiple page types with same-named fields on them (because they aren’t actually the same field from the database’s point of view).

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:4
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
gasmancommented, May 8, 2019

@brylie Assuming field_on_model is a field defined on the Contact model, then Contact.objects.child_of(self).filter(field_on_model="something") (without the specific()) should work.

2reactions
bryliecommented, May 8, 2019

Thanks for the quick response! It works! Will be glad to see this in the docs, as I have been spending nearly one hour trying to figure this out by guesswork 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

QuerySet API reference | Django documentation
Internally, a QuerySet can be constructed, filtered, sliced, and generally passed around without actually hitting the database. No database activity actually ...
Read more >
Filtering - Django REST framework
Often you will want your API to restrict the items that are returned by the queryset. The simplest way to filter the queryset...
Read more >
Django: Ordering a QuerySet based on a latest child models ...
The Django QuerySet documentation states: It is permissible to specify a multi-valued field to order the results by (for example, a ManyToManyField field)....
Read more >
Filtering QuerySets dynamically in Django - LogRocket Blog
Learn how to filter a Django QuerySet dynamically using AJAX, and build list pages for your web apps that allow filtering and pagination....
Read more >
QuerySet API reference — Django 1.5.12 documentation
Note : Don't use len() on QuerySet s if all you want to do is determine the number of records ... ...since the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found