Open tkhyn opened 5 years ago
Original report by Olivier Lefevre (Bitbucket: olefevre, GitHub: olefevre).
I created and used this through model:
class Group2Target(models.Model): group = models.ForeignKey(Group) target = GenericForeignKey(ct_field='target_type', fk_field='target_id') target_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) target_id = models.PositiveIntegerField()
(never mind what Group is: it is not the problem field). When I try to execute ControlGroup2Target.objects.values('target') I get:
FieldError: Cannot resolve keyword 'target' into field. Choices are: group, group_id, id, target, target_id, target_type, target_type_id
So you have to use target_id instead but the message is really confusing because "target" is listed as one of the valid choices!
Original comment by Thomas Khyn (Bitbucket: tkhyn, GitHub: tkhyn).
Maybe there is something I missed, but no use of GM2MField is made here, so it's unlikely to be related to django-gm2m. I guess you need to report the issue to the django developers.
GM2MField
django-gm2m
Original comment by Olivier Lefevre (Bitbucket: olefevre, GitHub: olefevre).
Yes this is related to django-gm2m: I said it is a through model. In another model there is this:
targets = GM2MField(through='Group2Target')
OK I see. Can you send the full stack trace leading to the exception to know if there is any way to catch it at the django-gm2m level?
The requested stack trace. stacktrace.txt
Original report by Olivier Lefevre (Bitbucket: olefevre, GitHub: olefevre).
I created and used this through model:
(never mind what Group is: it is not the problem field). When I try to execute ControlGroup2Target.objects.values('target') I get:
So you have to use target_id instead but the message is really confusing because "target" is listed as one of the valid choices!