[Django] #16117: Model Methods decorators

15 views
Skip to first unread message

Django

unread,
May 29, 2011, 6:19:37 AM5/29/11
to django-...@googlegroups.com
#16117: Model Methods decorators
----------------------------+----------------------------------------------
Reporter: haras | Owner: nobody
Type: | Status: new
Cleanup/optimization | Component: Database layer (models, ORM)
Milestone: 1.4 | Severity: Normal
Version: | Triage Stage: Unreviewed
Keywords: | Easy pickings: 0
Has patch: 0 |
----------------------------+----------------------------------------------
How about changing:
{{{
model_method.allow_tags = True
model_method.short_description = _('Model Method')
}}}

into:

{{{
@options(allow_tags=True, short_description=_('Model Method'))
}}}

or:

{{{
@allow_tags
@short_desctiption(_('Model Method'))
}}}
?


discussion at [https://groups.google.com/forum/#!topic/django-developers
/Ebe-nGumjug Django Developers Group]

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

Django

unread,
May 29, 2011, 8:54:48 AM5/29/11
to django-...@googlegroups.com
#16117: Model Methods decorators
---------------------------------------+-------------------------------
Reporter: haras | Owner: nobody
Type: New feature | Status: new
Milestone: 1.4 | Component: contrib.admin
Version: | Severity: Normal
Resolution: | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
---------------------------------------+-------------------------------
Changes (by jezdez):

* needs_better_patch: => 0
* component: Database layer (models, ORM) => contrib.admin
* needs_tests: => 0
* needs_docs: => 0
* type: Cleanup/optimization => New feature
* stage: Unreviewed => Accepted


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

Django

unread,
May 29, 2011, 8:56:33 AM5/29/11
to django-...@googlegroups.com
#16117: Provide decorators to easily mark functions/methods for as list_display
items or admin actions
---------------------------------------+-------------------------------
Reporter: haras | Owner: nobody
Type: New feature | Status: new
Milestone: 1.4 | Component: contrib.admin
Version: | Severity: Normal
Resolution: | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
---------------------------------------+-------------------------------

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

Django

unread,
May 29, 2011, 8:56:46 AM5/29/11
to django-...@googlegroups.com
#16117: Provide decorators to easily mark functions/methods as list_display items
or admin actions
---------------------------------------+-------------------------------
Reporter: haras | Owner: nobody
Type: New feature | Status: new
Milestone: 1.4 | Component: contrib.admin
Version: | Severity: Normal
Resolution: | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
---------------------------------------+-------------------------------

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

Django

unread,
Aug 2, 2011, 5:22:29 AM8/2/11
to django-...@googlegroups.com
#16117: Provide decorators to easily mark functions/methods as list_display items
or admin actions
---------------------------------------+-------------------------------
Reporter: haras | Owner: nobody
Type: New feature | Status: new
Milestone: 1.4 | Component: contrib.admin
Version: | Severity: Normal
Resolution: | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------+-------------------------------
Changes (by velmont):

* ui_ux: => 0


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

Django

unread,
Apr 6, 2012, 12:39:52 AM4/6/12
to django-...@googlegroups.com
#16117: Provide decorators to easily mark functions/methods as list_display items
or admin actions
-------------------------------+------------------------------------
Reporter: haras | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version:
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by kmike):

* cc: kmike84@… (added)


Comment:

I've released a simple app for this some time ago:
https://github.com/kmike/django-admin-decorators

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

Django

unread,
Aug 24, 2015, 8:14:35 AM8/24/15
to django-...@googlegroups.com
#16117: Provide decorators to easily mark functions/methods as list_display items
or admin actions
-------------------------------+------------------------------------
Reporter: haras | Owner: nobody

Type: New feature | Status: new
Component: contrib.admin | Version:
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by timgraham):

#25134 is a duplicate with some discussion.

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

Django

unread,
Sep 22, 2015, 8:08:43 PM9/22/15
to django-...@googlegroups.com
#16117: Provide decorators to easily mark functions/methods as list_display items
or admin actions
-------------------------------+------------------------------------
Reporter: haras | Owner: nobody

Type: New feature | Status: new
Component: contrib.admin | Version:
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by funkybob):

In discussion with someone this morning, I whipped up this

{{{
class admin_list(object):
def __init__(self, boolean=None, order_field=None, allow_tags=None,
short_description=None):
self.boolean = boolean
self.order_field = order_field
self.allow_tags = allow_tags
self.short_description=short_description

def __call__(self, attr):
if self.boolean is not None:
attr.boolean = self.boolean
if self.order_field is not None:
attr.admin_order_field = self.order_field
if self.allow_tags is not None:
attr.allow_tags = self.allow_tags
if self.short_description is not None:
attr.short_description = short_description
return attr
}}}

Then asked if anyone thought it'd be useful, and @timgraham pointed me to
this ticket. I'll dump this here for now... feel free to bike shed the
names, or I'll make a PR if you like.

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

Django

unread,
Sep 22, 2015, 8:45:51 PM9/22/15
to django-...@googlegroups.com
#16117: Provide decorators to easily mark functions/methods as list_display items
or admin actions
-------------------------------+------------------------------------
Reporter: haras | Owner: nobody

Type: New feature | Status: new
Component: contrib.admin | Version:
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by collinanderson):

Also, keep in mind allow_tags is deprecated #25135.

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

Django

unread,
Oct 12, 2020, 10:45:50 AM10/12/20
to django-...@googlegroups.com
#16117: Provide decorators to easily mark functions/methods as list_display items
or admin actions
-------------------------------------+-------------------------------------
Reporter: Matt Harasymczuk | Owner: Nick Pope
Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: admin, actions, | Triage Stage: Accepted
list_display, readonly_fields, |
methods, short_description, |
admin_order_field, boolean, |
empty_value_display, |
allowed_permissions |
Has patch: 1 | Needs documentation: 0

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

* keywords: =>
admin, actions, list_display, readonly_fields, methods,
short_description, admin_order_field, boolean, empty_value_display,
allowed_permissions
* owner: nobody => Nick Pope
* has_patch: 0 => 1
* version: => master
* status: new => assigned


Comment:

[https://github.com/django/django/pull/13532 PR]

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

Django

unread,
Nov 24, 2020, 4:52:20 AM11/24/20
to django-...@googlegroups.com
#16117: Provide decorators to easily mark functions/methods as list_display items
or admin actions
-------------------------------------+-------------------------------------
Reporter: Matt Harasymczuk | Owner: Nick Pope
Type: New feature | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: admin, actions, | Triage Stage: Ready for
list_display, readonly_fields, | checkin

methods, short_description, |
admin_order_field, boolean, |
empty_value_display, |
allowed_permissions |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Adam (Chainz) Johnson):

* stage: Accepted => Ready for checkin


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

Django

unread,
Jan 13, 2021, 11:19:47 AM1/13/21
to django-...@googlegroups.com
#16117: Provide decorators to easily mark functions/methods as list_display items
or admin actions
-------------------------------------+-------------------------------------
Reporter: Matt Harasymczuk | Owner: Nick Pope
Type: New feature | Status: closed
Component: contrib.admin | Version: master
Severity: Normal | Resolution: fixed

Keywords: admin, actions, | Triage Stage: Ready for
list_display, readonly_fields, | checkin
methods, short_description, |
admin_order_field, boolean, |
empty_value_display, |
allowed_permissions |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

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


Comment:

In [changeset:"920448539631b52dcee53bd32a880abbc9de18bd" 9204485]:
{{{
#!CommitTicketReference repository=""
revision="920448539631b52dcee53bd32a880abbc9de18bd"
Fixed #16117 -- Added decorators for admin action and display functions.

Refs #25134, #32099.
}}}

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

Django

unread,
Feb 22, 2021, 4:12:46 AM2/22/21
to django-...@googlegroups.com
#16117: Provide decorators to easily mark functions/methods as list_display items
or admin actions
-------------------------------------+-------------------------------------
Reporter: Matt Harasymczuk | Owner: Nick Pope
Type: New feature | Status: closed
Component: contrib.admin | Version: master
Severity: Normal | Resolution: fixed
Keywords: admin, actions, | Triage Stage: Ready for
list_display, readonly_fields, | checkin
methods, short_description, |
admin_order_field, boolean, |
empty_value_display, |
allowed_permissions |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by GitHub <noreply@…>):

In [changeset:"8f02a78695a6c07bc5b05499e6e6cf96bc25320f" 8f02a78]:
{{{
#!CommitTicketReference repository=""
revision="8f02a78695a6c07bc5b05499e6e6cf96bc25320f"
Refs #16117 -- Made @action and @display decorators importable from
django.contrib.gis.admin.
}}}

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

Django

unread,
Feb 22, 2021, 4:13:42 AM2/22/21
to django-...@googlegroups.com
#16117: Provide decorators to easily mark functions/methods as list_display items
or admin actions
-------------------------------------+-------------------------------------
Reporter: Matt Harasymczuk | Owner: Nick Pope
Type: New feature | Status: closed
Component: contrib.admin | Version: master
Severity: Normal | Resolution: fixed
Keywords: admin, actions, | Triage Stage: Ready for
list_display, readonly_fields, | checkin
methods, short_description, |
admin_order_field, boolean, |
empty_value_display, |
allowed_permissions |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"eccf40a3038bb38c4fd0e7c3ada03e7a9a02c091" eccf40a]:
{{{
#!CommitTicketReference repository=""
revision="eccf40a3038bb38c4fd0e7c3ada03e7a9a02c091"
[3.2.x] Refs #16117 -- Made @action and @display decorators importable
from django.contrib.gis.admin.

Backport of 8f02a78695a6c07bc5b05499e6e6cf96bc25320f from master
}}}

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

Reply all
Reply to author
Forward
0 new messages