How can I disable the Django Celery admin modules?

2019-02-03 15:22发布

问题:

I have no need to the celery modules in my Django admin. Is there a way I could remove it?

回答1:

To be more specific, in admin.py of any app inside INSTALLED_APPS after 'djcelery'

from django.contrib import admin
from djcelery.models import (
    TaskState, WorkerState, PeriodicTask, 
    IntervalSchedule, CrontabSchedule)

admin.site.unregister(TaskState)
admin.site.unregister(WorkerState)
admin.site.unregister(IntervalSchedule)
admin.site.unregister(CrontabSchedule)
admin.site.unregister(PeriodicTask)


回答2:

You can simply unregister celerys models like admin.site.unregister(CeleryModelIdoNotWantInAdmin)