To find unused Django views, look for view functions and classes that no urlpatterns entry references, then check templates and string references before you delete them. A whole-project scanner does the first part. Django calls a lot of code by name (views from URLconfs, receivers from decorators, middleware from settings.py, admin methods from list_display strings, model methods from templates), so every scanner needs some configuration before its output is trustworthy.

We built a Django 5.2 app with six known dead items and ran five tools on it. Here's what each found.


The test app

Live code that Django calls for you: a function view and a DetailView in urlpatterns, a ModelAdmin with a list_display method, a @receiver connected in AppConfig.ready(), middleware listed in MIDDLEWARE, a management command, application in wsgi.py, and Product.price_with_tax(), used only in a template.

Dead code:

# shop/views.py (excerpt)
from django.http import HttpResponse, JsonResponse      # JsonResponse: unused


def old_landing(request):                                # in no urlpatterns
    return HttpResponse("Welcome to the old shop")


@login_required
def old_account(request):                                # in no urlpatterns
    return HttpResponse("Your account (v1)")


class LegacyReportView(TemplateView):                    # in no urlpatterns
    template_name = "shop/report_v1.html"


def _format_price(value):                                # never called
    return f"${value:,.2f}"

Plus rebuild_search_index() in shop/signals.py, which nothing calls.


Results

ToolDead found (of 6)Live code flaggedNotes
Ruff 0.17.0, ruff check --select F,ARG .14Only the unused import; flags signature arguments Django requires (sender, **kwargs, *args, **options)
Vulture 2.16, vulture .629Every setting, both urlpatterns, admin, command, middleware, receiver
deadcode 2.4.1, deadcode .625Similar to Vulture; exits 0
Skylos 4.47.1, skylos .413Nine settings, application, a list_display method, a template-only method, a view's model attribute
Skylos 4.47.1, skylos . --confidence 8042application and the view's model attribute
Vulture 2.16, configured60Config below
Skylos 4.47.1, configured40Config below

The two items Skylos missed in every run are old_account (behind @login_required) and LegacyReportView (a class-based view). Both are known gaps in 4.47.1, explained below. If unused class-based views matter to you, use a configured Vulture for that check.

Skylos with defaults

$ skylos . --format concise
shop/admin.py:10  SKY-U001  unused function: ProductAdmin.price_display
shop/models.py:8  SKY-U001  unused function: Product.price_with_tax
shop/signals.py:13  SKY-U001  unused function: rebuild_search_index
shop/views.py:18  SKY-U001  unused function: old_landing
shop/views.py:31  SKY-U001  unused function: _format_price
shop/views.py:2  SKY-U002  unused import: JsonResponse
mysite/settings.py:1  SKY-U003  unused variable: SECRET_KEY
mysite/settings.py:2  SKY-U003  unused variable: DEBUG
mysite/settings.py:3  SKY-U003  unused variable: ALLOWED_HOSTS
mysite/settings.py:4  SKY-U003  unused variable: DEFAULT_AUTO_FIELD
mysite/settings.py:5  SKY-U003  unused variable: INSTALLED_APPS
mysite/settings.py:13  SKY-U003  unused variable: MIDDLEWARE
mysite/settings.py:19  SKY-U003  unused variable: ROOT_URLCONF
mysite/settings.py:20  SKY-U003  unused variable: TEMPLATES
mysite/settings.py:33  SKY-U003  unused variable: DATABASES
mysite/wsgi.py:6  SKY-U003  unused variable: application
shop/views.py:15  SKY-U003  unused variable: model
shop/views.py:28  SKY-U003  unused variable: template_name
shop/views.py:18  SKY-U006  unused parameter: request

It kept live the URL-routed views, the ModelAdmin class, the signal receiver, ShopConfig.ready(), the middleware, the management command and the model fields. The settings scored 60 and the methods named only in strings scored 60, so --confidence 80 drops them.

Skylos, configured

[tool.skylos.whitelist]
names = [
  "application",    # mysite/wsgi.py, loaded by the WSGI server
  "price_display",  # named in ProductAdmin.list_display
  "price_with_tax", # used in shop/templates/shop/product_detail.html
]

[tool.skylos.overrides."settings.py"]
whitelist = ["*"]
$ skylos . --select SKY-U001,SKY-U002,SKY-U004 --format concise
shop/signals.py:13  SKY-U001  unused function: rebuild_search_index
shop/views.py:18  SKY-U001  unused function: old_landing
shop/views.py:31  SKY-U001  unused function: _format_price
shop/views.py:2  SKY-U002  unused import: JsonResponse

--select limits the first pass to unused functions, imports and classes; class attributes such as model and unused parameters (SKY-U003, SKY-U006) are noisier on Django code.

Two more cases we tested on a copy of the app:

  • A tests.py module. Skylos treats files under tests/ or test/ and *_test.py as tests, not a file called tests.py, so a TestCase in shop/tests.py was reported as an unused class. Fix: [tool.skylos.overrides."tests.py"] with whitelist = ["*"], or move tests into a tests/ package.

  • @admin.display methods named in list_display were reported. Fix:

    [[tool.skylos.dead_code.entrypoints]]
    type = "method"
    decorators = ["admin.display", "admin.action"]
    reason = "Django admin display and action methods"
    

With both added, the output was the same four true findings. One caution: in 4.47.1, if pyproject.toml doesn't parse, Skylos ignores the whole [tool.skylos] section without a warning. Check it with python -c "import tomllib; tomllib.load(open('pyproject.toml', 'rb'))".

Vulture, configured

Adam Johnson's 2023 article is the best starting point. Its exclude, ignore_decorators and ignore_names settings, plus a five-line whitelist for the list_display method, the template-only method, a model field and two framework signatures, took Vulture from 29 false positives to none, with all six dead items still reported:

$ vulture
shop/signals.py:13: unused function 'rebuild_search_index' (60% confidence)
shop/views.py:2: unused import 'JsonResponse' (90% confidence)
shop/views.py:18: unused function 'old_landing' (60% confidence)
shop/views.py:22: unused function 'old_account' (60% confidence)
shop/views.py:27: unused class 'LegacyReportView' (60% confidence)
shop/views.py:31: unused function '_format_price' (60% confidence)

The full config and whitelist are in Vulture false positives: tested configs.


Other options, and what each misses

OptionWhat it doesWhat it misses
Vulture with Adam Johnson's configWhole-project unused code; the most complete result on our app once configuredTemplates; anything you put in ignore_names is hidden everywhere; no transitive dead code
django-deadcode 0.8.0 (MIT, Dec 2025)manage.py finddeadcode maps templates, URL patterns and views: URL names no template links to, templates nothing rendersUnused Python code. On our app it reported one URL name, product-list (the home page, which nothing links to because it's the entry URL), and none of the six dead functions. Needs django_deadcode in INSTALLED_APPS and a BASE_DIR setting
django-unused 0.1.4 (last release March 2018)manage.py unused views / templatesIt doesn't run on current Django. On Django 5.2 it failed on import; after we installed its undeclared dependencies six and whoosh, it failed on django.core.urlresolvers, a module removed in Django 2.0
coverage.py and access logsRuntime evidence: lines that never ran, routes nobody requestsCode your tests or traffic don't exercise looks dead even when it isn't; tests that call dead code make it look alive

What Skylos treats as used

From the framework rules in the 4.47.1 source, checked against the test app where it has the pattern:

Django conventionHow Skylos treats it
Function view referenced in any urlpatterns (path, re_path)Used
Class-based view used with .as_view(), and its get/post/... methodsUsed
CBV hooks such as get_queryset, get_context_data, form_valid on a class that directly subclasses a Django viewUsed
@receiver(...) handlers and functions passed to signal.connect(...)Used
ModelAdmin hooks and option attributes, functions listed in actions=[...], admin.site.register(Model, Admin) and @admin.registerUsed
Model hooks (save, clean, get_absolute_url, natural_key, ...), Meta, fieldsUsed
Form clean() and clean_<field>()Used
Management command Command, handle, add_argumentsUsed
MiddlewareMixin subclasses and their process_* methodsUsed
Template tags and filters registered with @register.filter, simple_tag, inclusion_tag, tagUsed
Migration RunPython callbacksUsed
Celery @shared_task / @app.taskUsed
DRF viewset actions (list, create, retrieve, ...), serializer validate, validate_<field>, to_representation, get_<field>Used

The base-class checks look at the direct base. If your view, model or admin inherits from your own base class (a project BaseAdminView, an abstract model), some of that handling no longer applies and you'll see more findings on that class.


What Skylos doesn't find

  • Unused class-based views, DRF views and serializers, forms, ModelAdmins and models that directly subclass a Django or DRF base are never reported, even when nothing uses them. Their unused methods are reported; the classes are not. LegacyReportView on the test app is an example.
  • Views behind certain decorators. Unused function views decorated with @login_required, @permission_required, @staff_member_required, @require_POST, @require_GET or @api_view are treated as used. old_account on the test app is an example.
  • Dead URLconfs. Skylos doesn't follow include("app.urls") strings. A view listed in a URLconf that nothing includes still counts as used (checked on a copy of the test app, even at --confidence 0).
  • Receivers that never connect. A @receiver in a module that is never imported (for example, a missing import in AppConfig.ready()) still counts as used (checked the same way).
  • Code near getattr dispatch. If reachable code calls something like getattr(self, f"do_{action}"), Skylos 4.47.1 stops reporting unused functions anywhere in the project, without a warning (tested on our Flask app). Check the output count before and after adding dynamic dispatch.
  • Templates. Skylos does not parse Django templates, including {% url %} tags. A model method or property used only in a template looks unused, so search your templates before deleting one.

Use Skylos for unused function views, helpers, admin actions, tasks, template-tag helpers and unused methods. Use a configured Vulture, or a manual search, for unused class-based views and decorated views. Use access logs for routes nobody calls.


A workflow that holds up

  1. First pass: skylos . --confidence 80, or Vulture with the Django config.
  2. Record what Django loads by name: settings, application, list_display methods, template-only methods, admin decorators.
  3. Check templates and strings for each finding: rg "name" templates/ shop/ before deleting a method or view.
  4. Preview removals: skylos clean . --dry-run lists the unused imports and functions it would delete (here: the import, old_landing, _format_price and rebuild_search_index); --apply writes them.
  5. Stop new dead code with a pull-request check: skylos cicd init --no-upload writes a GitHub Actions workflow that needs no Skylos account.

For the security side of a Django app, see Django security scanning: what static analysis catches.



Try it

pip install skylos
skylos . --confidence 80