Skip to content

Commit 2e88079

Browse files
makes settings and manage more modern.
1 parent 7b44c4f commit 2e88079

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

manage.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
23
import os
34
import sys
45

5-
if __name__ == "__main__":
6+
7+
def main():
8+
"""Run administrative tasks."""
69
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")
710
try:
811
from django.core.management import execute_from_command_line
9-
except ImportError:
10-
# The above import may fail for some other reason. Ensure that the
11-
# issue is really that Django is missing to avoid masking other
12-
# exceptions on Python 2.
13-
try:
14-
import django
15-
except ImportError:
16-
raise ImportError(
17-
"Couldn't import Django. Are you sure it's installed and "
18-
"available on your PYTHONPATH environment variable? Did you "
19-
"forget to activate a virtual environment?"
20-
)
21-
raise
12+
except ImportError as exc:
13+
raise ImportError(
14+
"Couldn't import Django. Are you sure it's installed and "
15+
"available on your PYTHONPATH environment variable? Did you "
16+
"forget to activate a virtual environment?"
17+
) from exc
2218
execute_from_command_line(sys.argv)
19+
20+
21+
if __name__ == "__main__":
22+
main()

myproject/settings.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
"""
1212

1313
import os
14+
from pathlib import Path
1415
from typing import List
1516

16-
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
17-
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
18+
BASE_DIR = Path(__file__).resolve().parent.parent
1819

1920

2021
# Quick-start development settings - unsuitable for production

0 commit comments

Comments
 (0)