Related name with %(app_label)s being an actual field?

17 views
Skip to first unread message

Jonty Needham

unread,
Nov 4, 2016, 12:40:00 PM11/4/16
to django...@googlegroups.com
Hi,

In an attempt to fix my earlier query about related names etc, it would appear that I've (half() fixed my issue.

I now have:

    submission = GenericRelation(
        MyModel,
        related_query_name='%(app_label)s_related_name')

So that's good and gives me the related names. However, when I come to use django filters, I get hit with the message:

FieldError: Cannot resolve keyword 'my_app_name_related_name into field. Choices are: %(app_label)s_related_name, etc etc etc.


What is causing this and how do I not have this?

Simon Charette

unread,
Nov 5, 2016, 4:33:34 AM11/5/16
to Django users
Hi Jonty,

While support for related_query_name was added in 1.6 it only supports app_label
and class_name interpolation since Django 1.10.

You can either upgrade to Django 1.10 or rely on related_name's support for app_label
and class_name interpolation as related_query_name defaults to related_name if
it's not explicitly defined.

Simon
Reply all
Reply to author
Forward
0 new messages