# order\_with\_respect\_to generated method names

**URL:** https://forum.djangoproject.com/t/order-with-respect-to-generated-method-names/24856
**Category:** ORM
**Created:** [October 28, 2023, 12:27pm UTC](https://forum.djangoproject.com/t/order-with-respect-to-generated-method-names/24856 "2023-10-28T12:27:10Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![zaharazod](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/zaharazod/32/16682_2.png) [@zaharazod](https://forum.djangoproject.com/u/zaharazod)
#### Post date: [October 28, 2023, 12:27pm UTC](https://forum.djangoproject.com/t/order-with-respect-to-generated-method-names/24856/1 "2023-10-28T12:27:10Z")

</div>

Hi! I have a hopefully quick question regarding order\_with\_respect\_to and the method names it generates on the “containing” model. Given the following model definition:

class PostContent(BlogObject):  
parent = models.ForeignKey(  
Post, related\_name=‘contents’, on\_delete=models.PROTECT)

the Post model now has a “set\_postcontent\_order()” method available; shouldn’t that be “set\_contents\_order()” (ie utilizing related\_name)? Wouldn’t this break if Post had multiple, differently ordered PostContent fields?

Thanks,  
Matt

---

<div class="post-metadata">

### Author: ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)
#### Post date: [October 28, 2023, 3:03pm UTC](https://forum.djangoproject.com/t/order-with-respect-to-generated-method-names/24856/2 "2023-10-28T15:03:32Z")

</div>

I don’t think so.

The `order_with_respect_to` is an attribute of the Meta class of the model containing the foreign key. You can only have one such definition, and it’s defined as a reference to the field name, not the model name. ([first sentence](https://docs.djangoproject.com/en/4.2/ref/models/options/#django.db.models.Options.order_with_respect_to))

In other words, if `Post` had multiple foreign key fields to `PostContent` named `pc1`, `pc2`, and `pc3`, you would pick one of them and define it as as the `order_with_respect_to`. That Django names the function `get_postcontent_order` doesn’t really affect this. You’re only going to have one of these in your model. (I’m guessing that the use of the lowercased model name in the function name has some internal significance, but I have no idea what that might be.)

But I’m not sure I see where a conflict can arise.
