1
0
mirror of https://github.com/django/django.git synced 2024-12-27 11:35:53 +00:00
django/tests/model_permalink/models.py
2013-02-26 14:36:57 +01:00

25 lines
633 B
Python

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)
@models.permalink
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])