Skip to content

Settings

Django settings for kartoza django project.

ASGI

ASGI config for core project.

It exposes the ASGI callable as a module-level variable named application.

For more information on this file, see https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/

CELERY

A celery config for the project.

create_scheduler_task

create_scheduler_task(
    task_name,
    task_name_desc,
    num_interval,
    interval_schedule,
)

Create periodic scheduler tasks.

Parameters:

Name Type Description Default
task_name

task_name

required
task_name_desc

Name/Description of the task

required
num_interval

Interval

required
interval_schedule

one of ['DAYS', 'HOURS']

required
Source code in django_project/core/celery.py
def create_scheduler_task(task_name, task_name_desc,
                          num_interval, interval_schedule):
    """
    Create periodic scheduler tasks.

    :param task_name: task_name
    :param task_name_desc: Name/Description of the task
    :param num_interval: Interval
    :param interval_schedule: one of ['DAYS', 'HOURS']
    """
    from importlib import import_module
    try:
        IntervalSchedule = (
            import_module('django_celery_beat.models').IntervalSchedule
        )

        PeriodicTask = (
            import_module('django_celery_beat.models').PeriodicTask
        )
        if interval_schedule == 'HOURS':
            schedule, _ = IntervalSchedule.objects.get_or_create(
                every=num_interval,
                period=IntervalSchedule.HOURS
            )
        elif interval_schedule == 'DAYS':
            schedule, _ = IntervalSchedule.objects.get_or_create(
                every=num_interval,
                period=IntervalSchedule.DAYS
            )
        PeriodicTask.objects.update_or_create(
            task=task_name,
            defaults={
                'name': task_name_desc,
                'interval': schedule
            }
        )
    except Exception as e:
        print(e)

URLS

Core URL Configuration.

The urlpatterns list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/4.1/topics/http/urls/

Examples:

Function views

1. Add an import:  from my_app import views
2. Add a URL to urlpatterns:  path('', views.home, name='home')

Class-based views

1. Add an import:  from other_app.views import Home
2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')

Including another URLconf

1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))

WSGI

WSGI config for core project.

It exposes the WSGI callable as a module-level variable named application.

For more information on this file, see https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/