django-baker icon indicating copy to clipboard operation
django-baker copied to clipboard

Error: 'ForeignKey' object has no attribute 'rel'

Open staskh opened this issue 6 years ago • 1 comments

Getting 'ForeignKey' object has no attribute 'rel' on administration view. Model file attached models.py.txt

staskh avatar Aug 20 '19 09:08 staskh

I also had this error when visiting the admin page for one of my models. It appears that field.rel was removed and so the call to field.rel.to.objects.count() in django_baker/admin.py fails. See https://docs.djangoproject.com/en/1.9/releases/1.9/#field-rel-changes.

If you don't mind losing admin filters, one work around is to implement get_list_filter() in each of your admin classes:

class MyModelAdmin(ExtendedModelAdminMixin, admin.ModelAdmin):
    extra_list_display = []
    extra_list_filter = []
    .....
    formfield_overrides = {}
    readonly_fields = []

    def get_list_filter(self, request):
        return ()

Iain-S avatar Aug 20 '19 16:08 Iain-S