I wanted to secure my Django Admin so I followed the steps in here and I implemented django-otp to the my website. The token works fine. I can login my admin page safely but my models doesn't show up in my admin page.
For example: Before the OTP Implementation I was able to post a new blog or something but now I cant at all. There are nothing about blogs in my admin.
I am logging as a superuser and I tried to create another superuser and logging but it didn't change.
I think this error might be caused by the admin.py file configurations, but I'm not sure.
Here is my urls.py
from django.contrib import admin
from django.urls import path, include, re_path
from django.conf import settings
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns # new
from django.conf import settings
from django.views.static import serve
from django.contrib.auth.models import User
from django_otp.admin import OTPAdminSite
from django_otp.plugins.otp_totp.models import TOTPDevice
from django_otp.plugins.otp_totp.admin import TOTPDeviceAdmin
class OTPAdmin(OTPAdminSite):
pass
admin_site = OTPAdmin(name='OTPAdmin')
admin_site.register(User)
admin_site.register(TOTPDevice, TOTPDeviceAdmin)
urlpatterns = [
path('admin/', admin_site.urls),
path('', include('pages.urls')),
path('', include('portfolio.urls')),
path('', include('services.urls')),
path('', include('blog.urls')),
re_path(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),
re_path(r'^static/(?P<path>.*)$', serve, {'document_root': settings.STATIC_ROOT}),
]
Here is an example of my admin.py
from django.contrib import admin
from .models import BlogPost
@admin.register(BlogPost)
class BlogPostAdmin(admin.ModelAdmin):
list_display = ('blogname', 'related_service', 'available', 'created_at' )
list_filter = ('available', 'related_service',)
search_fields = ('blogname',)
prepopulated_fields = {
'slug':('blogname',)
}