Whenever I add/remove/modify anything in models.py and the following commands the project does not make those changes to the database models.
python manage.py makemigrations
OR
python manage.py makemigrations
OR
Python manage.py migrate
All the above command throws the same error as below: " return self.cursor.execute(sql, params) django.db.utils.ProgrammingError: column "
Tried deleting the migrate folder (without deleting , running fake migrations , running zero migrations but nothing helped.
Please advise.
Models.py file is saved and includes:
class studentmaster(models.Model):
studentid = models.IntegerField(primary_key=True)
studentname = models.CharField(max_length=30)
isstaff= models.BooleanField(default=False)
when running migrations, the complete trace is provided below:
python manage.py migrate --fake
Traceback (most recent call last):
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: column loginapp_studentmaster.isstaff does not exist
LINE 1: ...udentid", "loginapp_studentmaster"."studentname", "loginapp_...
^
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/core/management/base.py", line 332, in execute
self.check()
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/core/management/base.py", line 364, in check
include_deployment_checks=include_deployment_checks,
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 58, in _run_checks
issues.extend(super()._run_checks(**kwargs))
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/core/management/base.py", line 351, in _run_checks
return checks.run_checks(**kwargs)
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/core/checks/registry.py", line 73, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/urls/resolvers.py", line 397, in check
for pattern in self.url_patterns:
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/utils/functional.py", line 36, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/urls/resolvers.py", line 536, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/utils/functional.py", line 36, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/urls/resolvers.py", line 529, in urlconf_module
return import_module(self.urlconf_name)
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/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 "/home/ankit/smartswypetest/smartswypetest/UserLogin/urls.py", line 18, in <module>
from loginapp import views
File "/home/ankit/smartswypetest/smartswypetest/loginapp/views.py", line 10, in <module>
from .forms import *
File "/home/ankit/smartswypetest/smartswypetest/loginapp/forms.py", line 32, in <module>
class AnnForm(forms.Form):
File "/home/ankit/smartswypetest/smartswypetest/loginapp/forms.py", line 42, in AnnForm
choices=[(str(s.studentid), s.studentname)for s in studentmaster.objects.all()],
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/db/models/query.py", line 272, in __iter__
self._fetch_all()
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/db/models/query.py", line 1179, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/db/models/query.py", line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1066, in execute_sql
cursor.execute(sql, params)
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
return super().execute(sql, params)
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/ankit/miniconda3/envs/sswypeenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column loginapp_studentmaster.isstaff does not exist
LINE 1: ...udentid", "loginapp_studentmaster"."studentname", "loginapp_...
migrate --fake
,makemigrations
and thenmigrate
. – scharette