2016-10-04 18:39:49 +00:00
|
|
|
import warnings
|
|
|
|
|
2011-03-14 05:22:39 +00:00
|
|
|
from django.db import models
|
2016-10-04 18:39:49 +00:00
|
|
|
from django.utils.deprecation import RemovedInDjango21Warning
|
2011-03-14 05:22:39 +00:00
|
|
|
|
2011-10-13 21:34:56 +00:00
|
|
|
|
2012-09-08 15:58:48 +00:00
|
|
|
def set_attr(name, value):
|
|
|
|
def wrapper(function):
|
|
|
|
setattr(function, name, value)
|
|
|
|
return function
|
|
|
|
return wrapper
|
|
|
|
|
|
|
|
|
2016-10-04 18:39:49 +00:00
|
|
|
with warnings.catch_warnings():
|
|
|
|
warnings.simplefilter('ignore', category=RemovedInDjango21Warning)
|
|
|
|
|
|
|
|
class Guitarist(models.Model):
|
|
|
|
name = models.CharField(max_length=50)
|
|
|
|
slug = models.CharField(max_length=50)
|
2011-03-14 05:22:39 +00:00
|
|
|
|
2016-10-04 18:39:49 +00:00
|
|
|
@models.permalink
|
|
|
|
def url(self):
|
|
|
|
"Returns the URL for this guitarist."
|
|
|
|
return ('guitarist_detail', [self.slug])
|
2012-09-08 15:58:48 +00:00
|
|
|
|
2016-10-04 18:39:49 +00:00
|
|
|
@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])
|