forked from DjangoAdminHackers/django-linkcheck
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't crash in display_url when object has no get_absolute_url
- Loading branch information
Showing
4 changed files
with
41 additions
and
10 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
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 |
---|---|---|
@@ -1,10 +1,22 @@ | ||
from linkcheck import Linklist | ||
from linkcheck.tests.sampleapp.models import Book | ||
from linkcheck.tests.sampleapp.models import Author, Book | ||
|
||
class SampleLinklist(Linklist): | ||
|
||
class BookLinklist(Linklist): | ||
""" Class to let linkcheck app discover fields containing links """ | ||
model = Book | ||
object_filter = {} | ||
html_fields = ['description'] | ||
|
||
linklists = {'Books': SampleLinklist} | ||
|
||
class AuthorLinklist(Linklist): | ||
""" Class to let linkcheck app discover fields containing links """ | ||
model = Author | ||
object_filter = {} | ||
url_fields = ['website'] | ||
|
||
|
||
linklists = { | ||
'Books': BookLinklist, | ||
'Authors': AuthorLinklist, | ||
} |
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 |
---|---|---|
@@ -1,8 +1,15 @@ | ||
from django.db import models | ||
|
||
|
||
class Book(models.Model): | ||
title = models.CharField(max_length=50) | ||
description = models.TextField() | ||
|
||
def get_absolute_url(self): | ||
return "/book/%s/" % self.id | ||
|
||
|
||
class Author(models.Model): | ||
# This model has purposefully no get_absolute_url | ||
name = models.CharField(max_length=50) | ||
website = models.URLField(blank=True) |
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