Opened 5 years ago

Closed 5 years ago

#31528 closed Bug (fixed)

collectstatic doesn't run staticfiles checks.

Reported by: Keryn Knight Owned by: Hasan Ramezani
Component: contrib.staticfiles Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Piecing this together from a user who is having trouble with staticfiles (who doesn't, at least once) on IRC.

the system checks framework has a check_finders which is invoked if django.contrib.staticfiles is in your INSTALLED_APPS which defers checks to each individually configured finder as finder.check() - this accounts for running the following line:

if not isinstance(settings.STATICFILES_DIRS, (list, tuple)):

which is intended to catch the problem scenario of STATICFILES_DIRS = () being edited to STATICFILES_DIRS = ("mypath") with no trailing comma to make it a tuple, rather than an iterable string.

However, the collectstatic management command has requires_system_checks = False so it appears possible to edit the value and directly run python manage.py collectstatic without the type being checked or the error raised.

Naively, I'm assuming that something like the following needs to occur:

for finder in get_finders():
    finder.check() # ignoring NotImplementedError
    # then somehow surface any errors back to stderr as if `requires_system_checks = True`

I've not delved deeply into the "surface errors" part.

Change History (4)

comment:1 by Mariusz Felisiak, 5 years ago

Summary: collectstatic management command ignores all system checks, including its own?collectstatic doesn't run staticfiles checks.
Triage Stage: UnreviewedAccepted

We should be able to run only staticfiles checks with self.check(app_configs) or by using Tags, self.check(tags=[...]).

comment:2 by Hasan Ramezani, 5 years ago

Owner: changed from nobody to Hasan Ramezani
Status: newassigned

comment:3 by Hasan Ramezani, 5 years ago

Has patch: set

comment:4 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In 87faeee4:

Fixed #31528 -- Made collectstatic management command run staticfiles checks.

Note: See TracTickets for help on using tickets.
Back to Top