-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Admin Model Not Integrating into Django Admin Page #38
Comments
Hi Scott, thanks for reporting this. I did not get this error on my side. Also this is the first time someone has issues with the admin panel not showing up in the admin site. Can you share the Python, Django and DRF versions you are using? |
Sure thing. Worth noting that I verified that this package was installed correctly (i.e. in Python==3.5.6 Edit: typo |
So, I was able to reproduce the issue with the versions you listed. I just had to run system checks after creating a new project and adding the DRF and DRF-api-key apps: $ ./manage.py check
SystemCheckError: System check identified some issues:
ERRORS:
<class 'rest_framework_api_key.admin.APIKeyAdmin'>: (admin.E108) The value of 'list_display[4]' refers to 'has_expired_func', which is not a callable, an attribute of 'APIKeyAdmin', or an attribute or method on 'rest_framework_api_key.APIKey'.
System check identified 1 issue (0 silenced). Upgrading the Django and DRF versions to the latest available did not fix this either, so this is definitely a serious bug! The following fixed the system checks:
def _has_expired(self) -> bool:
...
_has_expired.short_description = "Has expired"
_has_expired.boolean = True
has_expired = property(_has_expired)
If you're up for it, feel free to open a PR with these. :-) |
Excellent, thank you for following up with this in such a timely manner! Unfortunately I'm a bit busy to attempt a PR at the moment, but I'll keep it in mind if I get a moment. My temporary fix that I listed in the first comment is working well for my project, especially since I made many custom modifications in the form of subclassing your models. |
Gotcha, I'll try and find some time to publish the fix later today then. :-) I suppose this is affecting all users of 1.2, so it's best if we get this out asap.
We have an open issue to provide an abstract API key model to make it easier to customize API keys: #34. If that's something you'd be interested in, feel free to check it out and share your thoughts! |
Same is happening with Django 2.1.*, Python 3.7.3 and DRF 3.9 |
Released in v1.2.1. 👍 |
Went to add this app to my project and noticed it wasn't automatically added to my Django admin page. I tried manually adding it in my
admin.py
and it appeared:However, when I navigated to
Home/API Key Permissions/API Keys
I received the following error:AttributeError at /admin/rest_framework_api_key/apikey/ Unable to lookup 'has_expired_func' on APIKey or APIKeyAdmin
My temporary fix was to create a new admin model by subclassing the one given by this app:
Thereby removing
has_expired_func
fromlist_display
.The text was updated successfully, but these errors were encountered: