I am seeing these errors when I use the related_name parameter on my GM2MField.
#!python
.../site-packages/gm2m/monkeypatch.py:82: RemovedInDjango110Warning: 'get_field_by_name is an unofficial API that has been deprecated. You may be able to replace it with 'get_field()'
gfbn_old(old_names['tgt_fk'])[0],
.../site-packages/gm2m/monkeypatch.py:83: RemovedInDjango110Warning: 'get_field_by_name is an unofficial API that has been deprecated. You may be able to replace it with 'get_field()'
gfbn_new(new_names['tgt_fk'])[0],
.../site-packages/gm2m/monkeypatch.py:86: RemovedInDjango110Warning: 'get_field_by_name is an unofficial API that has been deprecated. You may be able to replace it with 'get_field()'
gfbn_old(old_names['tgt_ct'])[0],
...site-packages/gm2m/monkeypatch.py:87: RemovedInDjango110Warning: 'get_field_by_name is an unofficial API that has been deprecated. You may be able to replace it with 'get_field()'
gfbn_new(new_names['tgt_ct'])[0],
Look like the fix is pretty simple, replaced with calls to get_field, and removed the list index addressing.
#!python
# gm2m/mokneypatch.py, lines 62 to 91
if isinstance(old_field, GM2MField) \
or isinstance(new_field, GM2MField):
# Repoint the GFK to the other side
# we need to alter both fields of the GFK
old_names = old_field.rel.through._meta._field_names
new_names = new_field.rel.through._meta._field_names
gfbn_old = old_field.rel.through._meta.get_field
gfbn_new = new_field.rel.through._meta.get_field
if old_field.rel.through._meta.db_table == \
new_field.rel.through._meta.db_table:
# The field name didn't change, but some options did;
# we have to propagate this altering.
self._remake_table(
old_field.rel.through,
# We need the field that points to the target model,
# so we can tell alter_field to change it -
# this is m2m_reverse_field_name() (as opposed to
# m2m_field_name, which points to our model)
alter_fields=[(
gfbn_old(old_names['tgt_fk']),
gfbn_new(new_names['tgt_fk']),
),
(
gfbn_old(old_names['tgt_ct']),
gfbn_new(new_names['tgt_ct']),
)],
override_uniques=(old_names['src'], old_names['tgt_fk'],
old_names['tgt_ct']),
)
Too lazy to get setup to do a PR sorry, and haven't done any extensive testing. I am running python3.4 with Django 1.9.
Original comment by Thomas Khyn (Bitbucket: tkhyn, GitHub: tkhyn).
Hi @abartlett and thanks for the report.
This bug has actually been addressed in 7bc1234dbd23, which has not landed in a release yet. That'll come soon.
Original report by Ashley Bartlett (Bitbucket: Ash, GitHub: Ash).
I am seeing these errors when I use the
related_name
parameter on my GM2MField.Look like the fix is pretty simple, replaced with calls to get_field, and removed the list index addressing.
Too lazy to get setup to do a PR sorry, and haven't done any extensive testing. I am running python3.4 with Django 1.9.