Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #15604 -- Changed django.db.models.permalink to use wraps() so …
…that it doesn't eat the docstring. Thanks for the report, sfllaw. Also added tests. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15798 bcc190cf-cafb-0310-a4f2-bffc1f526a37
- Loading branch information
1 parent
3a5b87c
commit 72c5733
Showing
5 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.db import models | ||
|
||
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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from django.test import TestCase | ||
from regressiontests.model_permalink.models import Guitarist | ||
|
||
class PermalinkTests(TestCase): | ||
urls = 'regressiontests.model_permalink.urls' | ||
|
||
def test_permalink(self): | ||
g = Guitarist(name='Adrien Moignard', slug='adrienmoignard') | ||
self.assertEqual(g.url(), '/guitarists/adrienmoignard/') | ||
|
||
def test_wrapped_docstring(self): | ||
"Methods using the @permalink decorator retain their docstring." | ||
g = Guitarist(name='Adrien Moignard', slug='adrienmoignard') | ||
self.assertEqual(g.url.__doc__, "Returns the URL for this guitarist.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.conf.urls.defaults import * | ||
|
||
urlpatterns = patterns('', | ||
url(r'^guitarists/(\w{1,50})/$', 'unimplemented_view_placeholder', name='guitarist_detail'), | ||
) |