Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I disable the Django Celery admin modules?

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

like image 680
Mridang Agarwalla Avatar asked May 13 '12 13:05

Mridang Agarwalla


People also ask

How do I restrict access to admin pages in Django?

Django admin allows access to users marked as is_staff=True . To disable a user from being able to access the admin, you should set is_staff=False . This holds true even if the user is a superuser. is_superuser=True .

How can I remove extra's from Django admin panel?

You can add another class called Meta in your model to specify plural display name. For example, if the model's name is Category , the admin displays Categorys , but by adding the Meta class, we can change it to Categories . Literally saved my life!

Can we customize Django admin panel?

We have a lot of tools in Django to customize it to our own needs and in this article, we'll learn how to customize the admin interface and add multiple features: Let's setup your project, add models into models.py and register your models.


3 Answers

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)
like image 174
okm Avatar answered Sep 18 '22 14:09

okm


Updated version looks like:

from django_celery_beat.models import (
    IntervalSchedule,
    CrontabSchedule,
    SolarSchedule,
    ClockedSchedule,
    PeriodicTask,
)

admin.site.unregister(SolarSchedule)
admin.site.unregister(ClockedSchedule)
admin.site.unregister(PeriodicTask)
admin.site.unregister(IntervalSchedule)
admin.site.unregister(CrontabSchedule)

You always can get a list of registered models via:

admin.site._registry
like image 29
Noah Avatar answered Sep 22 '22 14:09

Noah


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

like image 40
beezz Avatar answered Sep 20 '22 14:09

beezz