Skip to content

runmodwsgi errors with newer Django settings #931

@pjmichalski

Description

@pjmichalski

Hi, I've been using the Django management command runmodwsgi for many projects, usually without issue. However, I just started a new project and this time I got an error: "PosixPath object has no attribute 'endswith'." The error is triggered on line 1093 in /server/init.py.

I did some debugging and discovered that the "target" object on that line was a Path object pointing to the directory defined by the STATIC_ROOT setting. Older versions of Django used the os.path.join() method to define that directory, which returns a string, but new versions encourage using the pathlib.Path approach, something like STATIC_ROOT = BASE_DIR / 'collect_static'.

Obviously I can just cast that as a string within the settings file, but I imagine more and more users will have that defined as a Path object. For compatibility you might want to explicitly cast the "target" object as a string so other users don't encounter the same issue.

Thanks for the mod_wsgi package, I've used it extensively for years.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions