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