Admin Model Not Integrating into Django Admin Page
See original GitHub issueWent 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:
from rest_framework_api_key.admin import APIKeyAdmin
from rest_framework_api_key.models import APIKey
admin.site.register(APIKey, APIKeyAdmin)
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:
from rest_framework_api_key.admin import APIKeyAdmin
from rest_framework_api_key.models import APIKey
class BaseAPIKeyAdmin(APIKeyAdmin):
list_display = (
"name",
"prefix",
"created",
"expiry_date",
"revoked",
)
admin.site.register(APIKey, BaseAPIKeyAdmin)
Thereby removing has_expired_func
from list_display
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Django admin page not showing user models - Stack Overflow
Regisrar your models in admin.py file. from . models import Model_Name. Then you can register your models in two ways: I) ...
Read more >custom model not showing up in django admin - YouTube
custom model not showing up in django admin | admin.sites.register(MyModel) doesn't work [ Solved ]. 2,215 views ...
Read more >Django Tutorial Part 4: Django admin site - MDN Web Docs
First we'll show you how to register the models with the admin site, then we'll show you how to login and create some...
Read more >The Django admin site
One of the most powerful parts of Django is the automatic admin interface. It reads metadata from your models to provide a quick,...
Read more >Django admin integration
Although the child models are registered too, they won't be shown in the admin index page. This only happens when show_in_index is set...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
Sure thing. Worth noting that I verified that this package was installed correctly (i.e. in
INSTALLED_APPS
) and that I had run the migrations.Python==3.5.6 Django==2.1.5 djangorestframework==3.7.7
Edit: typo