[Django] #32268: ProgrammingError: column doesnt exist when adding new field or removing a field after makemigrations or migrate command

9 views
Skip to first unread message

Django

unread,
Dec 14, 2020, 8:57:46 PM12/14/20
to django-...@googlegroups.com
#32268: ProgrammingError: column doesnt exist when adding new field or removing a
field after makemigrations or migrate command
-------------------------------------+-------------------------------------
Reporter: gvm2121 | Owner: nobody
Type: Bug | Status: new
Component: | Version: 2.2
Migrations | Keywords: migrations,
Severity: Normal | makemigrations,ProgrammingError
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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

--
Ticket URL: <https://code.djangoproject.com/ticket/32268>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 14, 2020, 8:59:18 PM12/14/20
to django-...@googlegroups.com
#32268: ProgrammingError: column doesnt exist when adding new field or removing a
field after makemigrations or migrate command
-------------------------------------+-------------------------------------
Reporter: gvm2121 | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 2.2
Severity: Normal | Resolution:
Keywords: migrations, | Triage Stage:
makemigrations,ProgrammingError | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by gvm2121:

Old description:

> 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.

New description:

packages/django/db/models/query.py, line 649, in latest

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32268#comment:1>

Django

unread,
Dec 15, 2020, 1:02:43 AM12/15/20
to django-...@googlegroups.com
#32268: Column doesn't exist when adding new field or removing a field after

makemigrations or migrate command
-------------------------------------+-------------------------------------
Reporter: gvm2121 | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 2.2
Severity: Normal | Resolution: invalid

Keywords: migrations, | Triage Stage:
makemigrations,ProgrammingError | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/32268#comment:2>

Reply all
Reply to author
Forward
0 new messages