Skip to content

Conversation

SebCorbin
Copy link

When filtering on a CountryField from a relation, the admin will break with a FieldError: Cannot resolve keyword 'country' into field. Choices are: ...

Full example code:

# models.py
class Contact(models.Model):
    country = CountryField(
        verbose_name=_("Country"),
        blank=True,
        null=True,
    )


class Payment(models.Model):
    contact = models.ForeignKey(
        "myapp.Contact", verbose_name=_("Contact"), on_delete=models.RESTRICT
    )
# admin.py
class PaymentAdmin(ModelAdmin):
    model = Payment
    list_filter = [
        ("contact__country", CountryFilter),
    ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants