Reputation: 87
So I am currently in a virtual environment, and when I typed the command line:
python manage.py migrate
and I encounter this problem:
> Traceback (most recent call last):
> File "manage.py", line 24, in <module>
> execute_from_command_line(sys.argv)
> File "C:\Users\DUCNGU~1\Desktop\HAULER~1\api\vnenv\lib\site-packages\django\core\management\__init__.py",
> line 371, in execute_from_command_line
> utility.execute()
> File "C:\Users\DUCNGU~1\Desktop\HAULER~1\api\vnenv\lib\site-packages\django\core\management\__init__.py",
> line 317, in execute
> settings.INSTALLED_APPS
> File "C:\Users\DUCNGU~1\Desktop\HAULER~1\api\vnenv\lib\site-packages\django\conf\__init__.py",
> line 56, in __getattr__
> self._setup(name)
> File "C:\Users\DUCNGU~1\Desktop\HAULER~1\api\vnenv\lib\site-packages\django\conf\__init__.py",
> line 43, in _setup
> self._wrapped = Settings(settings_module)
> File "C:\Users\DUCNGU~1\Desktop\HAULER~1\api\vnenv\lib\site-packages\django\conf\__init__.py",
> line 106, in __init__
> mod = importlib.import_module(self.SETTINGS_MODULE)
> File "C:\Users\DUCNGU~1\Desktop\HAULER~1\api\vnenv\lib\importlib\__init__.py",
> line 126, in import_module
> return _bootstrap._gcd_import(name[level:], package, level)
> File "<frozen importlib._bootstrap>", line 994, in _gcd_import
> File "<frozen importlib._bootstrap>", line 971, in _find_and_load
> File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
> File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
> File "<frozen importlib._bootstrap_external>", line 678, in exec_module
> File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
> File "C:\Users\Duc Nguyen\Desktop\HaulerAds\api\settings.py", line 104, in <module>
> 'PORT': int(os.getenv('POSTGRES_PORT')),
> TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
My current Django version 2.0.3. I checked the python pass and I have the proper path. Please help, thank you!
Upvotes: 2
Views: 6417
Reputation: 8525
You're trying to retrieve POSTGRES_POST
, in the os.environ
but it doesn't exist.
int()
can't convert NoneType
.
If it's possible that the key does not exist in your environment.
you can set a default value:
'PORT': int(os.getenv('POSTGRES_PORT',5432))
The second argument is the default port in case that key doesn't exist in os.environ
Upvotes: 3
Reputation: 476493
It looks like you use PostgreSQL as a database system, but Django has trouble finding the port you use for the PostgreSQL database.
You can set the parameter for the command locally executing the migrations with:
POSTGRES_PORT=5432 python manage.py migrate
or another port if you configured PostgreSQL in a different way (the default port for a PostgreSQL server is 5432, but you can of course have picked a different one yourself).
Upvotes: 1