Skip to content

Commit

Permalink
fix: detailed django celery beat installation (#483)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasvinclav authored Jun 13, 2024
1 parent 045920f commit 4ad2d0c
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -842,26 +842,41 @@ from django_celery_beat.models import (
PeriodicTask,
SolarSchedule,
)

from django_celery_beat.admin import ClockedScheduleAdmin as BaseClockedScheduleAdmin
from django_celery_beat.admin import CrontabScheduleAdmin as BaseCrontabScheduleAdmin
from django_celery_beat.admin import PeriodicTaskAdmin as BasePeriodicTaskAdmin
from django_celery_beat.admin import PeriodicTaskForm, TaskSelectWidget

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

@admin.register(PeriodicTask)
class PeriodicTaskAdmin(ModelAdmin):

class UnfoldTaskSelectWidget(UnfoldAdminSelectWidget, TaskSelectWidget):
pass


class UnfoldPeriodicTaskForm(PeriodicTaskForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["task"].widget = UnfoldAdminTextInputWidget()
self.fields["regtask"].widget = UnfoldTaskSelectWidget()


@admin.register(PeriodicTask)
class PeriodicTaskAdmin(BasePeriodicTaskAdmin, ModelAdmin):
form = UnfoldPeriodicTaskForm


@admin.register(IntervalSchedule)
class IntervalScheduleAdmin(ModelAdmin):
pass


@admin.register(CrontabSchedule)
class CrontabScheduleAdmin(ModelAdmin):
class CrontabScheduleAdmin(BaseCrontabScheduleAdmin, ModelAdmin):
pass


Expand All @@ -870,7 +885,7 @@ class SolarScheduleAdmin(ModelAdmin):
pass

@admin.register(ClockedSchedule)
class ClockedScheduleAdmin(ModelAdmin):
class ClockedScheduleAdmin(BaseClockedScheduleAdmin, ModelAdmin):
pass
```

Expand Down

0 comments on commit 4ad2d0c

Please sign in to comment.