Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the ROOT_DIR definition #2578

Merged
merged 1 commit into from
Apr 30, 2020
Merged

Improve the ROOT_DIR definition #2578

merged 1 commit into from
Apr 30, 2020

Conversation

luzfcb
Copy link
Collaborator

@luzfcb luzfcb commented Apr 29, 2020

Description

  • Make sure to resolve symbolic links, uses an absolute path in ROOT_DIR, and raise an error if the path does not exist by using the resolve method. https://docs.python.org/3/library/pathlib.html#pathlib.Path.resolve
  • Use parent.parent.parent because "Explicit is better than implicit" and because it causes less cognitive overload that parents[2].

Rationale

A similar change will be sent when django 3.1 is released.

@Andrew-Chen-Wang
Copy link
Contributor

Should wsgi.py and asgi.py with the app_path name also be changed, too?

Copy link
Member

@browniebroke browniebroke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@luzfcb
Copy link
Collaborator Author

luzfcb commented Apr 30, 2020

Should wsgi.py and asgi.py with the app_path name also be changed, too?

By consistency, I think so

and raise an error if the path does not exist by using the "resolve" method.

Use "parent.parent.parent" instead of "parents[2]"
@luzfcb
Copy link
Collaborator Author

luzfcb commented Apr 30, 2020

Added fixes for wsgi.py and asgi.py

@luzfcb luzfcb merged commit b2a136c into master Apr 30, 2020
@luzfcb luzfcb deleted the ensure-absolute-path branch April 30, 2020 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants