[Django] #32977: conditionalize Class Meta. I want to achieve something like this. How can i do it?

7 views
Skip to first unread message

Django

unread,
Jul 31, 2021, 10:52:55 AM7/31/21
to django-...@googlegroups.com
#32977: conditionalize Class Meta. I want to achieve something like this. How can i
do it?
--------------------------------------------+------------------------
Reporter: hellorahulnarang | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------------+------------------------
if self.name_format == "First name Last name":
class Meta:
ordering = ['first_name', 'last_name']
elif self.name_format == "Last name First name":
class Meta:
ordering = ["last_name","first_name"]
elif self.name_format == "Last name, First name":
class Meta:
ordering = ["last_name","first_name"]
else:
class Meta:
ordering = ["first_name","last_name"]

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

Django

unread,
Jul 31, 2021, 1:10:07 PM7/31/21
to django-...@googlegroups.com
#32977: conditionalize Class Meta. I want to achieve something like this. How can i
do it?
----------------------------------+--------------------------------------
Reporter: hellorahulnarang | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 3.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

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


Old description:

> if self.name_format == "First name Last name":
> class Meta:
> ordering = ['first_name', 'last_name']
> elif self.name_format == "Last name First name":
> class Meta:
> ordering = ["last_name","first_name"]
> elif self.name_format == "Last name, First name":
> class Meta:
> ordering = ["last_name","first_name"]
> else:
> class Meta:
> ordering = ["first_name","last_name"]

New description:

{{{


if self.name_format == "First name Last name":
class Meta:
ordering = ['first_name', 'last_name']
elif self.name_format == "Last name First name":
class Meta:
ordering = ["last_name","first_name"]
elif self.name_format == "Last name, First name":
class Meta:
ordering = ["last_name","first_name"]
else:
class Meta:
ordering = ["first_name","last_name"]
}}}

--

Comment:

Please don't use Trac as a support channel. Closing per
TicketClosingReasons/UseSupportChannels.

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

Reply all
Reply to author
Forward
0 new messages