mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
refs #12836 - Added a test to assure permalink wraps method attributes
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
def set_attr(name, value):
|
||||
def wrapper(function):
|
||||
setattr(function, name, value)
|
||||
return function
|
||||
return wrapper
|
||||
|
||||
|
||||
class Guitarist(models.Model):
|
||||
name = models.CharField(max_length=50)
|
||||
slug = models.CharField(max_length=50)
|
||||
@@ -9,3 +16,9 @@ class Guitarist(models.Model):
|
||||
def url(self):
|
||||
"Returns the URL for this guitarist."
|
||||
return ('guitarist_detail', [self.slug])
|
||||
|
||||
@models.permalink
|
||||
@set_attr('attribute', 'value')
|
||||
def url_with_attribute(self):
|
||||
"Returns the URL for this guitarist and holds an attribute"
|
||||
return ('guitarist_detail', [self.slug])
|
||||
|
||||
Reference in New Issue
Block a user