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 11#!/usr/bin/env python
2+ """Django's command-line utility for administrative tasks."""
23import os
34import 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 ()
Original file line number Diff line number Diff line change 1111"""
1212
1313import os
14+ from pathlib import Path
1415from 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
You can’t perform that action at this time.
0 commit comments