2011-03-14 06:22:39 +01:00
|
|
|
from django.db import models
|
|
|
|
|
2011-10-13 23:34:56 +02:00
|
|
|
|
2012-09-08 17:58:48 +02:00
|
|
|
def set_attr(name, value):
|
|
|
|
def wrapper(function):
|
|
|
|
setattr(function, name, value)
|
|
|
|
return function
|
|
|
|
return wrapper
|
|
|
|
|
|
|
|
|
2011-03-14 06:22:39 +01: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 17:58:48 +02: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])
|