Opened 5 years ago

Closed 5 years ago

#15604 closed (fixed)

django.db.models.permalink eats docstring

Reported by: sfllaw Owned by: nobody
Component: Core (Other) Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


The django.db.models.permalink decorator eats docstrings, along with the other metadata that it is wrapping. That's because it's not using functools.wraps on its inner function.

It should be defined like this:

from django.utils.decorators import wraps

def permalink(func):
    from django.core.urlresolvers import reverse
    def inner(*args, **kwargs):
        bits = func(*args, **kwargs)
        return reverse(bits[0], None, *bits[1:3])
    return inner

Change History (3)

comment:1 Changed 5 years ago by sfllaw

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Whoops, that wraps line should be:


comment:2 Changed 5 years ago by adrian

  • Triage Stage changed from Unreviewed to Accepted

Good improvement. I'll add this along with some tests.

comment:3 Changed 5 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

In [15798]:

Fixed #15604 -- Changed django.db.models.permalink to use wraps() so that it doesn't eat the docstring. Thanks for the report, sfllaw. Also added tests.

Note: See TracTickets for help on using tickets.
Back to Top