Opened 4 years ago
Closed 4 years ago
#32268 closed Bug (invalid)
Column doesn't exist when adding new field or removing a field after makemigrations or migrate command
Reported by: | Gonzalo Vera | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 2.2 |
Severity: | Normal | Keywords: | migrations, makemigrations, ProgrammingError |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
This issues raises when you want to add or delete a field from a model and that model is used in a form before. We have here the egg-chicken problem. makemigrations parse the form (i do not why) and he detect changes on those fields and raise the error. (Bold fonts):
I fixed that issue commenting or replacing all the lines with bases.objects.all() (the compromised model) by anything or an empty string on the form. After that i ran makemigrations again, migrate, re-composed fake lines on the forms and that was right.
I think this issue could be on migrations documentation or be fixed. Also didnt found solutions on Django 3.
Thanks very much.
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/gvera/Fynsa/fynsa_src/fynsa/BASES/admin.py", line 3, in <module>
from .formularios_bases import f_facturas_bases
File "/home/gvera/Fynsa/fynsa_src/fynsa/BASES/formularios_bases.py", line 27, in <module>
class f_fechas_comite(forms.Form):
File "/home/gvera/Fynsa/fynsa_src/fynsa/BASES/formularios_bases.py", line 29, in f_fechas_comite
fecha_final = forms.DateField(widget=forms.DateInput(attrs={'class':'form-control mx-2','type':'date'}),label='fecha final', required=True, initial=bases.objects.latest('fecha'))
File "/home/gvera/Fynsa/fynsa_env/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, kwargs)
File /home/gvera/Fynsa/fynsa_env/lib/python3.6/site-packages/django/db/models/query.py, line 649, in latest
Change History (2)
comment:1 by , 4 years ago
Description: | modified (diff) |
---|
comment:2 by , 4 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Summary: | ProgrammingError: column doesnt exist when adding new field or removing a field after makemigrations or migrate command → Column doesn't exist when adding new field or removing a field after makemigrations or migrate command |
I'm sorry but from the current description I don't understand what kind of issue you're trying to report.
makemigrations
has nothing to do with forms and you cannot work with nonexistent fields. It looks like a support question, so please use as a support channel. Closing per TicketClosingReasons/UseSupportChannels.