[Django] #29156: Increase 'order_with_respect_to' features

2 views
Skip to first unread message

Django

unread,
Feb 23, 2018, 7:05:59 PM2/23/18
to django-...@googlegroups.com
#29156: Increase 'order_with_respect_to' features
-------------------------------------+-------------------------------------
Reporter: tapia | Owner: nobody
Type: New | Status: new
feature |
Component: Database | Version: 2.0
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
With `order_with_respect_to`, we can do something like this:

{{{
class Book(models.Model):
pass

class Chapter(models.Model):
book = models.ForeignKey(Book, on_delete=models.CASCADE)

class Meta:
order_with_respect_to = 'book'
}}}

It would be very nice to add some obvious features to this feature, for
example:

* `book.get_chapter_order()` returns the IDs of the chapters. Why not the
chapter objects itself?

* Given a chapter, we can get the next and the previous chapters, but we
can't easily get that chapter's order.

* It would be very nice to be able to add a chapter directly in a specific
position, pretty much like python's `insert`. For example:
`book.insert_chapter(chapter, 3)`

I know it's a very broad request, but, if you guys like the idea, I'd love
to take a look if I can add the functions myself (one at a time, to get
your approval on each of them).

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

Django

unread,
Feb 23, 2018, 10:32:58 PM2/23/18
to django-...@googlegroups.com
#29156: Enhance the model methods added when Meta.order_with_respect_to is used
-------------------------------------+-------------------------------------
Reporter: César García Tapia | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: 2.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Someday/Maybe
Has patch: 0 | Needs documentation: 0

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

* stage: Unreviewed => Someday/Maybe


Comment:

Ideally, a ticket should propose one feature rather than several. I'm not
sure what complexity might be involved in these issues, but I guess we
could evaluate a patch.

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

Reply all
Reply to author
Forward
0 new messages