[Django] #24693: Add model Options.label property

45 views
Skip to first unread message

Django

unread,
Apr 23, 2015, 10:54:35 AM4/23/15
to django-...@googlegroups.com
#24693: Add model Options.label property
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
There are many places in Django that construct a dotted path like this:
`'%s.%s' % (model._meta.app_label, model._meta.object_name)`

It would by DRYer to add a property to the Options class in
django/db/models/options.py that returned the dotted path. I'm proposing
the name "label".

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

Django

unread,
Apr 23, 2015, 12:11:00 PM4/23/15
to django-...@googlegroups.com
#24693: Add model Options.label property
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by aaugustin):

Yes please!

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

Django

unread,
Apr 24, 2015, 6:15:28 AM4/24/15
to django-...@googlegroups.com
#24693: Add model Options.label property
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by MarkusH):

+1

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

Django

unread,
Apr 24, 2015, 9:26:34 AM4/24/15
to django-...@googlegroups.com
#24693: Add model Options.label property
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: johngian
Type: | Status: assigned

Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by johngian):

* owner: nobody => johngian
* status: new => assigned


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

Django

unread,
Apr 24, 2015, 12:35:21 PM4/24/15
to django-...@googlegroups.com
#24693: Add model Options.label property
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: johngian
Type: | Status: assigned
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by timgraham):

We also want to add a `label_lower` property that returns `'%s.%s' %
(model._meta.app_label, model._meta.model_name)` as that's another
repeated pattern.

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

Django

unread,
Apr 24, 2015, 12:40:22 PM4/24/15
to django-...@googlegroups.com
#24693: Add model Options.label property
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: johngian
Type: | Status: assigned
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by bmispelon):

What's the advantage of doing `options.label_lower` rather than
`options.label.lower()`?

Or are these two different things?

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

Django

unread,
Apr 24, 2015, 12:41:15 PM4/24/15
to django-...@googlegroups.com
#24693: Add model Options.label property
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: johngian
Type: | Status: assigned
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by MarkusH):

* cc: MarkusH (added)


Comment:

`options.app_label` is never converted to lower case.

--
Ticket URL: <https://code.djangoproject.com/ticket/24693#comment:6>

Django

unread,
Apr 24, 2015, 12:43:09 PM4/24/15
to django-...@googlegroups.com
#24693: Add model Options.label property
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: johngian
Type: | Status: assigned
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by bmispelon):

Ah yes, that makes sense. Sorry for the noise :)

--
Ticket URL: <https://code.djangoproject.com/ticket/24693#comment:7>

Django

unread,
Apr 26, 2015, 4:52:43 PM4/26/15
to django-...@googlegroups.com
#24693: Add model Options.label property
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner:
Type: | delgiudices
Cleanup/optimization | Status: assigned

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by delgiudices):

* owner: johngian => delgiudices


--
Ticket URL: <https://code.djangoproject.com/ticket/24693#comment:8>

Django

unread,
Apr 26, 2015, 5:14:41 PM4/26/15
to django-...@googlegroups.com
#24693: Add model Options.label property
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner:
Type: | delgiudices
Cleanup/optimization | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by delgiudices):

Added pull request: https://github.com/django/django/pull/4566

--
Ticket URL: <https://code.djangoproject.com/ticket/24693#comment:9>

Django

unread,
Apr 26, 2015, 5:41:22 PM4/26/15
to django-...@googlegroups.com
#24693: Add model Options.label property
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner:
Type: | delgiudices
Cleanup/optimization | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1

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

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


--
Ticket URL: <https://code.djangoproject.com/ticket/24693#comment:10>

Django

unread,
Apr 26, 2015, 5:43:31 PM4/26/15
to django-...@googlegroups.com
#24693: Add model Options.label property
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner:
Type: | delgiudices
Cleanup/optimization | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by MarkusH):

About the documentation for this PR: I think we should make
`options.label` and `options.label_lower` public API.

--
Ticket URL: <https://code.djangoproject.com/ticket/24693#comment:11>

Django

unread,
Apr 26, 2015, 8:16:02 PM4/26/15
to django-...@googlegroups.com
#24693: Add model Options.label property
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner:
Type: | delgiudices
Cleanup/optimization | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by delgiudices):

I've added tests, changes in the docs, looked for places in django source
code old labels were used and replaced with `model._meta.label` or
`model._meta.label_lower`

--
Ticket URL: <https://code.djangoproject.com/ticket/24693#comment:12>

Django

unread,
Apr 29, 2015, 12:53:22 PM4/29/15
to django-...@googlegroups.com
#24693: Add model Options.label property
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner:
Type: | delgiudices
Cleanup/optimization | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* needs_docs: 1 => 0
* needs_tests: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/24693#comment:13>

Django

unread,
Apr 29, 2015, 2:17:14 PM4/29/15
to django-...@googlegroups.com
#24693: Add model Options.label property
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner:
Type: | delgiudices
Cleanup/optimization | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/24693#comment:14>

Django

unread,
Apr 30, 2015, 9:15:47 AM4/30/15
to django-...@googlegroups.com
#24693: Add model Options.label property
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner:
Type: | delgiudices
Cleanup/optimization | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

* cc: alasdair@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/24693#comment:15>

Django

unread,
May 1, 2015, 11:04:19 AM5/1/15
to django-...@googlegroups.com
#24693: Add model Options.label property
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner:
Type: | delgiudices
Cleanup/optimization | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

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

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/24693#comment:16>

Django

unread,
May 2, 2015, 10:58:59 AM5/2/15
to django-...@googlegroups.com
#24693: Add model Options.label property
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner:
Type: | delgiudices
Cleanup/optimization | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Markus Holtermann <info@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"69ddc1b3da043195a0f4e09211d395724b42c70b" 69ddc1b]:
{{{
#!CommitTicketReference repository=""
revision="69ddc1b3da043195a0f4e09211d395724b42c70b"
Fixed #24693 -- Added label and label_lower property to Model._meta
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24693#comment:17>

Reply all
Reply to author
Forward
0 new messages