A Django app that will analyze and report on links in any model that you register with it.
A fairly flexible app that will analyze and report on links in any model that you register with it.
Links can be bare (urls or image and file fields) or embedded in HTML (linkcheck handles the parsing). It’s fairly easy to override methods of the Linkcheck object should you need to do anything more complicated (like generate URLs from slug fields etc).
You should run its management command via cron or similar to check external links regularly to see if their status changes. All links are checked automatically when objects are saved. This is handled by signals.
django-linkchecks requires Python 2.7 and Django 1.8. It is Python 3 compatible.
Install app to somewhere on your Python path (e.g. pip install django-linkcheck).
Add 'linkcheck' to your settings.INSTALLED_APPS.
Add a file named linklists.py to every app (see an example in examples/linklists.py) that either:
- has models that contain content (e.g. url/image fields, chunks of markup or anything that gets transformed into a IMG or HREF when displayed
- can be the target of a link - i.e. is addressed by a url - in this case make sure it has an instance method named ‘get_absolute_url’
Run ./manage.py migrate.
Add to your root url config:
View /admin/linkcheck/ from your browser.
The file notifications.py is completely optional. It works with django-admin-blocks to display a notification about broken links as shown in the screenshot above.
We are aware that this documentation is on the brief side of things so any suggestions for elaboration or clarification would be gratefully accepted.
If django-filebrowser is present on your path then linkcheck will listen to the post-upload, delete and rename signals and update itself according
- Tests can be run standalone by using the runtests.py script in linkcheck root:
- $ python runtests.py
If you want to run linkcheck tests in the context of your project, you should include ‘linkcheck.tests.sampleapp’ in your INSTALLED_APPS setting.