Django custom admin site
there are some major issue that are not easily fixable.
if you want to use this library the best practice is to have both djagno's default admin and black knight's admin running side by side.
you can find the demo project in demo directory
pip install black-knight
create a new file in your main project directory
myproject/admin.py
# admin.py
from black_knight.admin import AdminSite
class KnightAdmin(AdminSite):
pass
knight = KnightAdmin()
add black_knight in your installed apps
myproject/settings.py
# settings.py
INSTALLED_APPS = [
...
'black_knight',
...
]
add new admin url in your urls.py
myproject/urls.py
# import your AdminSite instance
from myproject.admin import knight
urlpatterns = [
...
path('admin/', knight.urls),
path('old-admin/', admin.site.urls),
...
]
register your admins with the new knight
as well.
myapp/admin.py
from black_knight.admin import ModelAdmin
from myproject.admin import knight
from django.contrib import admin
from .models import MyModel
class MyModelAdmin(ModelAdmin):
pass
admin.site.register(MyModel, MyModelAdmin)
knight.register(MyModel, MyModelAdmin)
you also need to change your models.py
myapp/models.py
# replace all the models.XXXField with fields.XXXField
from black_knight import fields
from django.db import models
class MyModel(models.Model):
+ title = fields.CharField(max_length=50)
- title = models.CharField(max_length=50)