brash-area-42337
04/27/2023, 10:22 AM./pants run <path to file>:manage -- makemigrations accounts
which shows migrations have happened but when I run ./pants run <path to file>:manage -- migrate
or ./pants run <path to file>:manage -- migrate accounts
where accounts is the name of the app the models are located, it shows that
Operations to perform:
Apply all migrations: accounts, admin, auth, contenttypes, sessions
Running migrations:
No migrations to apply.
happy-kitchen-89482
04/29/2023, 12:51 AM:manage
to the target? You should be able to do pants run path/to/manage.py
happy-kitchen-89482
04/29/2023, 12:51 AMpants run path/to:manage
(i.e., using the address of a pex_binary target)?happy-kitchen-89482
04/29/2023, 12:53 AMpants run <path to file>:manage -- makemigrations accounts
it says it has created a new migration file? Does that new file show up in your source tree? (for example does git status
show it as a new file?)happy-kitchen-89482
04/29/2023, 12:59 AMpants run
runs files in a sandbox, so the new migration gets created there but doesn't get copied back to the real location in the source tree. So when you pants run
to apply the migration, there is no new migration available.happy-kitchen-89482
04/29/2023, 1:04 AMrun_goal_use_sandbox=False
on the manage.py
. Which you can do with an override:happy-kitchen-89482
04/29/2023, 1:05 AMpython_sources(
overrides={
"manage.py": {
"run_goal_use_sandbox": False,
"restartable": True,
},
},
happy-kitchen-89482
04/29/2023, 1:05 AMhappy-kitchen-89482
04/29/2023, 1:05 AMhappy-kitchen-89482
04/29/2023, 1:06 AMhappy-kitchen-89482
04/29/2023, 1:07 AMbrash-area-42337
05/01/2023, 3:23 PM./pants run path/to/file:manage
as an address to the pex binary target
this below is my pex_binary for manage.py
pex_binary(
name="manage",
entry_point="manage.py",
dependencies=[
"fleetdatabaseFinal:fleetdatabaseFinal",
"accounts:accounts",
"3rdparty:reqs#psycopg2-binary",
"3rdparty:reqs#gunicorn",
"3rdparty:reqs#djangorestframework",
],
restartable=True,
inherit_path="prefer",
)
let me set run_goal_use_sandbox=false
the same way I set the restartablebrash-area-42337
05/01/2023, 3:25 PMrun_goal_use_sandbox
setting in the 4 services in the repobrash-area-42337
05/01/2023, 3:35 PMbrash-area-42337
05/01/2023, 4:01 PMbrash-area-42337
05/01/2023, 4:25 PMkennan@medad:~/NPA/fleet-backend$ ./pants run fleetdatabaseFinal:manage -- migrate
System check identified some issues:
WARNINGS:
accounts.CustomUser.groups: (fields.W340) null has no effect on ManyToManyField.
Operations to perform:
Apply all migrations: accounts, admin, auth, contenttypes, sessions
Running migrations:
No migrations to apply.
brash-area-42337
05/02/2023, 10:44 AMhappy-kitchen-89482
05/02/2023, 1:06 PMpants run path/to/manage.py
instead of using the address and set run_goal_use_sandbox=false
on the source file, as I showed in the example (if that does change the migration file then I'll explain the difference between the two...)brash-area-42337
05/04/2023, 9:13 AMpants run path/to/manage.py
I get this exception below yet I included the 'python-dotenv' package in the requirements file
kennan@medad:~/NPA/fleet-backend$ ./pants run fleetdatabaseFinal/manage.py -- makemigrations
Traceback (most recent call last):
File "/home/kennan/.cache/pants/named_caches/pex_root/venvs/c327cad8531010afb442b743400c471a24792439/ee3bffdf8d6817038d2c7bb7f11bbf094d378a77/lib/python3.9/site-packages/django/core/management/base.py", line 402, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/kennan/.cache/pants/named_caches/pex_root/venvs/c327cad8531010afb442b743400c471a24792439/ee3bffdf8d6817038d2c7bb7f11bbf094d378a77/lib/python3.9/site-packages/django/core/management/base.py", line 443, in execute
self.check()
File "/home/kennan/.cache/pants/named_caches/pex_root/venvs/c327cad8531010afb442b743400c471a24792439/ee3bffdf8d6817038d2c7bb7f11bbf094d378a77/lib/python3.9/site-packages/django/core/management/base.py", line 475, in check
all_issues = checks.run_checks(
File "/home/kennan/.cache/pants/named_caches/pex_root/venvs/c327cad8531010afb442b743400c471a24792439/ee3bffdf8d6817038d2c7bb7f11bbf094d378a77/lib/python3.9/site-packages/django/core/checks/registry.py", line 88, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/home/kennan/.cache/pants/named_caches/pex_root/venvs/c327cad8531010afb442b743400c471a24792439/ee3bffdf8d6817038d2c7bb7f11bbf094d378a77/lib/python3.9/site-packages/django/core/checks/caches.py", line 64, in check_file_based_cache_is_absolute
for alias, config in settings.CACHES.items():
File "/home/kennan/.cache/pants/named_caches/pex_root/venvs/c327cad8531010afb442b743400c471a24792439/ee3bffdf8d6817038d2c7bb7f11bbf094d378a77/lib/python3.9/site-packages/django/conf/__init__.py", line 92, in __getattr__
self._setup(name)
File "/home/kennan/.cache/pants/named_caches/pex_root/venvs/c327cad8531010afb442b743400c471a24792439/ee3bffdf8d6817038d2c7bb7f11bbf094d378a77/lib/python3.9/site-packages/django/conf/__init__.py", line 79, in _setup
self._wrapped = Settings(settings_module)
File "/home/kennan/.cache/pants/named_caches/pex_root/venvs/c327cad8531010afb442b743400c471a24792439/ee3bffdf8d6817038d2c7bb7f11bbf094d378a77/lib/python3.9/site-packages/django/conf/__init__.py", line 190, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/home/kennan/NPA/fleet-backend/fleetdatabaseFinal/settings.py", line 101, in <module>
from dotenv import load_dotenv
ModuleNotFoundError: No module named 'dotenv'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/kennan/.cache/pants/named_caches/pex_root/venvs/c327cad8531010afb442b743400c471a24792439/ee3bffdf8d6817038d2c7bb7f11bbf094d378a77/pex", line 236, in <module>
runpy.run_module(module_name, run_name="__main__", alter_sys=True)
File "/usr/lib/python3.9/runpy.py", line 225, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib/python3.9/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/kennan/NPA/fleet-backend/fleetdatabaseFinal/manage.py", line 21, in <module>
main()
File "/home/kennan/NPA/fleet-backend/fleetdatabaseFinal/manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/home/kennan/.cache/pants/named_caches/pex_root/venvs/c327cad8531010afb442b743400c471a24792439/ee3bffdf8d6817038d2c7bb7f11bbf094d378a77/lib/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/home/kennan/.cache/pants/named_caches/pex_root/venvs/c327cad8531010afb442b743400c471a24792439/ee3bffdf8d6817038d2c7bb7f11bbf094d378a77/lib/python3.9/site-packages/django/core/management/__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/kennan/.cache/pants/named_caches/pex_root/venvs/c327cad8531010afb442b743400c471a24792439/ee3bffdf8d6817038d2c7bb7f11bbf094d378a77/lib/python3.9/site-packages/django/core/management/base.py", line 415, in run_from_argv
connections.close_all()
File "/home/kennan/.cache/pants/named_caches/pex_root/venvs/c327cad8531010afb442b743400c471a24792439/ee3bffdf8d6817038d2c7bb7f11bbf094d378a77/lib/python3.9/site-packages/django/utils/connection.py", line 84, in close_all
for conn in self.all(initialized_only=True):
File "/home/kennan/.cache/pants/named_caches/pex_root/venvs/c327cad8531010afb442b743400c471a24792439/ee3bffdf8d6817038d2c7bb7f11bbf094d378a77/lib/python3.9/site-packages/django/utils/connection.py", line 76, in all
return [
File "/home/kennan/.cache/pants/named_caches/pex_root/venvs/c327cad8531010afb442b743400c471a24792439/ee3bffdf8d6817038d2c7bb7f11bbf094d378a77/lib/python3.9/site-packages/django/utils/connection.py", line 73, in __iter__
return iter(self.settings)
File "/home/kennan/.cache/pants/named_caches/pex_root/venvs/c327cad8531010afb442b743400c471a24792439/ee3bffdf8d6817038d2c7bb7f11bbf094d378a77/lib/python3.9/site-packages/django/utils/functional.py", line 57, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/kennan/.cache/pants/named_caches/pex_root/venvs/c327cad8531010afb442b743400c471a24792439/ee3bffdf8d6817038d2c7bb7f11bbf094d378a77/lib/python3.9/site-packages/django/utils/connection.py", line 45, in settings
self._settings = self.configure_settings(self._settings)
File "/home/kennan/.cache/pants/named_caches/pex_root/venvs/c327cad8531010afb442b743400c471a24792439/ee3bffdf8d6817038d2c7bb7f11bbf094d378a77/lib/python3.9/site-packages/django/db/utils.py", line 148, in configure_settings
databases = super().configure_settings(databases)
File "/home/kennan/.cache/pants/named_caches/pex_root/venvs/c327cad8531010afb442b743400c471a24792439/ee3bffdf8d6817038d2c7bb7f11bbf094d378a77/lib/python3.9/site-packages/django/utils/connection.py", line 50, in configure_settings
settings = getattr(django_settings, self.settings_name)
File "/home/kennan/.cache/pants/named_caches/pex_root/venvs/c327cad8531010afb442b743400c471a24792439/ee3bffdf8d6817038d2c7bb7f11bbf094d378a77/lib/python3.9/site-packages/django/conf/__init__.py", line 92, in __getattr__
self._setup(name)
File "/home/kennan/.cache/pants/named_caches/pex_root/venvs/c327cad8531010afb442b743400c471a24792439/ee3bffdf8d6817038d2c7bb7f11bbf094d378a77/lib/python3.9/site-packages/django/conf/__init__.py", line 79, in _setup
self._wrapped = Settings(settings_module)
File "/home/kennan/.cache/pants/named_caches/pex_root/venvs/c327cad8531010afb442b743400c471a24792439/ee3bffdf8d6817038d2c7bb7f11bbf094d378a77/lib/python3.9/site-packages/django/conf/__init__.py", line 190, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/home/kennan/NPA/fleet-backend/fleetdatabaseFinal/settings.py", line 101, in <module>
from dotenv import load_dotenv
ModuleNotFoundError: No module named 'dotenv'
brash-area-42337
05/04/2023, 10:00 AM