File tree Expand file tree Collapse file tree 2 files changed +17
-16
lines changed Expand file tree Collapse file tree 2 files changed +17
-16
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env python
2
+ """Django's command-line utility for administrative tasks."""
2
3
import os
3
4
import sys
4
5
5
- if __name__ == "__main__" :
6
+
7
+ def main ():
8
+ """Run administrative tasks."""
6
9
os .environ .setdefault ("DJANGO_SETTINGS_MODULE" , "myproject.settings" )
7
10
try :
8
11
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
22
18
execute_from_command_line (sys .argv )
19
+
20
+
21
+ if __name__ == "__main__" :
22
+ main ()
Original file line number Diff line number Diff line change 11
11
"""
12
12
13
13
import os
14
+ from pathlib import Path
14
15
from typing import List
15
16
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
18
19
19
20
20
21
# Quick-start development settings - unsuitable for production
You can’t perform that action at this time.
0 commit comments