[Django] #29983: Paths when using Windows from an Ubuntu project

21 views
Skip to first unread message

Django

unread,
Nov 23, 2018, 5:25:16 PM11/23/18
to django-...@googlegroups.com
#29983: Paths when using Windows from an Ubuntu project
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
thewhisperinyourears |
Type: Bug | Status: new
Component: | Version: 2.0
contrib.staticfiles |
Severity: Normal | Keywords: paths, settings
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Apparently there is an issue hen you are using linux (Ubuntu) and copy and
paste your project to Windows. The Paths don't work. I had to change the
settings in my STATICFILES_DIRS from os.path.join(BASE_DIR,
'myapp/static') to os.path.join(BASE_DIR, 'myapp', 'static')

--
Ticket URL: <https://code.djangoproject.com/ticket/29983>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 23, 2018, 5:30:29 PM11/23/18
to django-...@googlegroups.com
#29983: Paths when using Windows from an Ubuntu project
-------------------------------------+-------------------------------------
Reporter: | Owner: Curtis
thewhisperinyourears | Maloney
Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 2.0
Severity: Normal | Resolution:
Keywords: paths, settings | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Curtis Maloney):

* owner: nobody => Curtis Maloney
* status: new => assigned
* stage: Unreviewed => Accepted


Comment:

I was helping this user on IRC, and they were getting confusing errors
when running "collectstatic" or "findstatic" about the path not matching.

It turned out to be a conflict with joining Windows-style paths with Unix-
style paths, as mentioned above.

I'm going to look at replacing uses of os.path.join and its ilk with
pathlib, which does not suffer this problem.

--
Ticket URL: <https://code.djangoproject.com/ticket/29983#comment:1>

Django

unread,
Nov 23, 2018, 5:44:51 PM11/23/18
to django-...@googlegroups.com
#29983: Paths when using Windows from an Ubuntu project
-------------------------------------+-------------------------------------
Reporter: | Owner: Curtis
thewhisperinyourears | Maloney
Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 2.0
Severity: Normal | Resolution:
Keywords: paths, settings | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

I'm surprised this hasn't come up before. What does the error look like?

The documentation for `STATICFILES_DIRS` days, "these paths should use
Unix-style forward slashes, even on Windows". I guess the problem is that
the way `BASE_DIR` is generated on Windows using backslashes. It's not
clear to me what Django can do about this but we'll see what Curtis comes
up with.

--
Ticket URL: <https://code.djangoproject.com/ticket/29983#comment:2>

Django

unread,
Nov 23, 2018, 8:34:32 PM11/23/18
to django-...@googlegroups.com
#29983: Paths when using Windows from an Ubuntu project
-------------------------------------+-------------------------------------
Reporter: | Owner: Curtis
thewhisperinyourears | Maloney
Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 2.0
Severity: Normal | Resolution:
Keywords: paths, settings | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Curtis Maloney):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/29983#comment:3>

Django

unread,
Nov 26, 2018, 9:27:14 AM11/26/18
to django-...@googlegroups.com
#29983: Replace os.path with pathlib.Path in project template and docs

-------------------------------------+-------------------------------------
Reporter: | Owner: Curtis
thewhisperinyourears | Maloney
Type: | Status: assigned
Cleanup/optimization |
Component: Core (Other) | Version: 2.0
Severity: Normal | Resolution:
Keywords: paths, settings | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* component: contrib.staticfiles => Core (Other)
* needs_better_patch: 0 => 1
* type: Bug => Cleanup/optimization


Comment:

The patch doesn't work because `os.path.join(BASE_DIR, 'db.sqlite3')`
returns a string while `BASE_DIR / 'db.sqlite3'` returns a `PosixPath`.
The documentation would have to use `str(BASE_DIR / 'db.sqlite3')`
everywhere or Django would have to convert `PosixPath` to string.

--
Ticket URL: <https://code.djangoproject.com/ticket/29983#comment:4>

Django

unread,
Nov 1, 2019, 8:32:52 PM11/1/19
to django-...@googlegroups.com
#29983: Replace os.path with pathlib.Path in project template and docs
-------------------------------------+-------------------------------------
Reporter: | Owner: Curtis
thewhisperinyourears | Maloney
Type: | Status: assigned
Cleanup/optimization |
Component: Core (Other) | Version: 2.0
Severity: Normal | Resolution:
Keywords: paths, settings | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jon Dufresne):

* needs_better_patch: 1 => 0


Comment:

I have resurrected the original patch with a fix for SQLite.

[https://github.com/django/django/pull/12005 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/29983#comment:5>

Django

unread,
Nov 2, 2019, 7:03:07 AM11/2/19
to django-...@googlegroups.com
#29983: Replace os.path with pathlib.Path in project template and docs
-------------------------------------+-------------------------------------
Reporter: | Owner: Curtis
thewhisperinyourears | Maloney
Type: | Status: assigned
Cleanup/optimization |
Component: Core (Other) | Version: 2.0
Severity: Normal | Resolution:
Keywords: paths, settings | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz):

I'm not sure if various Django settings requiring a path (template `DIRS`,
`STATIC/MEDIA_ROOT`, etc.) all support path inputs. Shouldn't we check and
add tests for those before changing the project settings template?

--
Ticket URL: <https://code.djangoproject.com/ticket/29983#comment:6>

Django

unread,
Nov 5, 2019, 5:32:39 AM11/5/19
to django-...@googlegroups.com
#29983: Replace os.path with pathlib.Path in project template and docs
-------------------------------------+-------------------------------------
Reporter: | Owner: Jon
thewhisperinyourears | Dufresne

Type: | Status: assigned
Cleanup/optimization |
Component: Core (Other) | Version: 2.0
Severity: Normal | Resolution:
Keywords: paths, settings | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* owner: Curtis Maloney => Jon Dufresne
* needs_tests: 0 => 1


Comment:

Assigning Jon, since he's picked this up; marking as needs tests, since I
think Claude is right, we have had regressions from moving to `Path`.

--
Ticket URL: <https://code.djangoproject.com/ticket/29983#comment:7>

Django

unread,
Nov 6, 2019, 2:08:34 AM11/6/19
to django-...@googlegroups.com
#29983: Replace os.path with pathlib.Path in project template and docs
-------------------------------------+-------------------------------------
Reporter: | Owner: Jon
thewhisperinyourears | Dufresne
Type: | Status: assigned
Cleanup/optimization |
Component: Core (Other) | Version: 2.0
Severity: Normal | Resolution:
Keywords: paths, settings | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"92e5abd7a3dbbea88b3d43d5790f94e276bc6dff" 92e5abd7]:
{{{
#!CommitTicketReference repository=""
revision="92e5abd7a3dbbea88b3d43d5790f94e276bc6dff"
Refs #29983 -- Added test for FIXTURES_DIRS pathlib support.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29983#comment:8>

Django

unread,
Nov 6, 2019, 2:21:05 AM11/6/19
to django-...@googlegroups.com
#29983: Replace os.path with pathlib.Path in project template and docs
-------------------------------------+-------------------------------------
Reporter: | Owner: Jon
thewhisperinyourears | Dufresne
Type: | Status: assigned
Cleanup/optimization |
Component: Core (Other) | Version: 2.0
Severity: Normal | Resolution:
Keywords: paths, settings | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"1c4c68dfed289093aaa2baf86bac7826c91e59ce" 1c4c68d]:
{{{
#!CommitTicketReference repository=""
revision="1c4c68dfed289093aaa2baf86bac7826c91e59ce"
Refs #29983 -- Added test for FILE_UPLOAD_TEMP_DIR pathlib support.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29983#comment:9>

Django

unread,
Nov 6, 2019, 3:33:46 AM11/6/19
to django-...@googlegroups.com
#29983: Replace os.path with pathlib.Path in project template and docs
-------------------------------------+-------------------------------------
Reporter: | Owner: Jon
thewhisperinyourears | Dufresne
Type: | Status: assigned
Cleanup/optimization |
Component: Core (Other) | Version: 2.0
Severity: Normal | Resolution:
Keywords: paths, settings | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"fbbff7f80870bc3e98de4a2fc9cd853949842fd0" fbbff7f]:
{{{
#!CommitTicketReference repository=""
revision="fbbff7f80870bc3e98de4a2fc9cd853949842fd0"
Refs #29983 -- Added pathlib.Path support to the file email backend.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29983#comment:10>

Django

unread,
Nov 6, 2019, 4:01:45 AM11/6/19
to django-...@googlegroups.com
#29983: Replace os.path with pathlib.Path in project template and docs
-------------------------------------+-------------------------------------
Reporter: | Owner: Jon
thewhisperinyourears | Dufresne
Type: | Status: assigned
Cleanup/optimization |
Component: Core (Other) | Version: 2.0
Severity: Normal | Resolution:
Keywords: paths, settings | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"74f2a58b3a5319d2d450c367293f03ad88c10894" 74f2a58b]:
{{{
#!CommitTicketReference repository=""
revision="74f2a58b3a5319d2d450c367293f03ad88c10894"
Refs #29983 -- Added tests for FileBasedCache pathlib support.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29983#comment:11>

Django

unread,
Nov 7, 2019, 4:27:17 AM11/7/19
to django-...@googlegroups.com
#29983: Replace os.path with pathlib.Path in project template and docs
-------------------------------------+-------------------------------------
Reporter: | Owner: Jon
thewhisperinyourears | Dufresne
Type: | Status: assigned
Cleanup/optimization |
Component: Core (Other) | Version: 2.0
Severity: Normal | Resolution:
Keywords: paths, settings | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"77aa74cb70dd85497dbade6bc0f394aa41e88c94" 77aa74c]:
{{{
#!CommitTicketReference repository=""
revision="77aa74cb70dd85497dbade6bc0f394aa41e88c94"
Refs #29983 -- Added support for using pathlib.Path in all settings.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29983#comment:12>

Django

unread,
Nov 7, 2019, 4:59:08 AM11/7/19
to django-...@googlegroups.com
#29983: Replace os.path with pathlib.Path in project template and docs
-------------------------------------+-------------------------------------
Reporter: | Owner: Jon
thewhisperinyourears | Dufresne
Type: | Status: assigned
Cleanup/optimization |
Component: Core (Other) | Version: 2.0
Severity: Normal | Resolution:
Keywords: paths, settings | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/29983#comment:13>

Django

unread,
Nov 7, 2019, 5:12:09 AM11/7/19
to django-...@googlegroups.com
#29983: Replace os.path with pathlib.Path in project template and docs
-------------------------------------+-------------------------------------
Reporter: | Owner: Jon
thewhisperinyourears | Dufresne
Type: | Status: closed

Cleanup/optimization |
Component: Core (Other) | Version: 2.0
Severity: Normal | Resolution: fixed

Keywords: paths, settings | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson <carlton.gibson@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"26554cf5d1e96db10d0d5f4b69683a22fb82fdf8" 26554cf5]:
{{{
#!CommitTicketReference repository=""
revision="26554cf5d1e96db10d0d5f4b69683a22fb82fdf8"
Fixed #29983 -- Replaced os.path() with pathlib.Path in project template
and docs.

Thanks Curtis Maloney for the original patch.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29983#comment:14>

Django

unread,
Apr 21, 2020, 6:08:47 AM4/21/20
to django-...@googlegroups.com
#29983: Replace os.path with pathlib.Path in project template and docs
-------------------------------------+-------------------------------------
Reporter: | Owner: Jon
thewhisperinyourears | Dufresne
Type: | Status: closed
Cleanup/optimization |
Component: Core (Other) | Version: 2.0
Severity: Normal | Resolution: fixed
Keywords: paths, settings | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton@…>):

In [changeset:"150c3d13a6fdf1a89a0fa90a8f8687fe3757a015" 150c3d13]:
{{{
#!CommitTicketReference repository=""
revision="150c3d13a6fdf1a89a0fa90a8f8687fe3757a015"
Refs #29983 -- Fixed displaying pathlib.Path database name in flush
command's inputs.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29983#comment:15>

Reply all
Reply to author
Forward
0 new messages