jazzband / django-authority

A Django app that provides generic per-object-permissions for Django's auth app and helpers to create custom permission checks.
http://django-authority.readthedocs.org
BSD 3-Clause "New" or "Revised" License
292 stars 57 forks source link

GenericForeignKeyRawIdWidget with Django 1.11 #68

Open mikebq opened 4 years ago

mikebq commented 4 years ago

I am porting an app to Django 1.11 and found that if I look at individual permissions an error occurs. It comes from GenericForeignKeyRawIdWidget. I have had a look at the code in question and I am trying to get understand what is going on, it seems a little confused: https://github.com/jazzband/django-authority/blob/master/authority/widgets.py#L22-L26 The __init__ method in the class is calling the __init__ method of the base class' base class (so it misses a level of initialisation, which I think is not a good idea). However the parameters for GenericForeignKeyRawIdWidget.__init__ are not sufficient to call ForeignKeyRawIdWidget.__init__.

So essentially for a GET against /authority/permission/21852/change/ using Django 1.11.28 results in an AttributeError: 'GenericForeignKeyRawIdWidget' object has no attribute 'rel' It blows up in /site-packages/django/contrib/admin/widgets.py in get_context, line 139. However though changing the base class of GenericForeignKeyRawIdWidget to forms.TextInput does prevent this error, but is that the right thing to do?

If anyone has any advice or clues of how to have this behave then thank you in advance :)