django-task icon indicating copy to clipboard operation
django-task copied to clipboard

something wrong with the task URL

Open engragy opened this issue 2 years ago • 0 comments

  • Django Task version: 2.0.6
  • Django version: 4.1.5
  • Python version: 3.8.10
  • Operating System: Ubuntu 20.04

Description

hello there my friend, first i would like to thank you for this awesome project. i have followed the instruction from the git-hub page and tasks are running fine in my development machine, but i have some issues (do not know if it is my bad or not).

here is what i did:

  • starting the task from signals

    @receiver(post_save, sender=Project)
    def create_project_folders(sender, instance, created, **kwargs):
        # start new task and its job with related info
        command = CreateProjectFoldersCommand()
        command.handle(project=instance)  # passing data to job function to create the task, job
    
  • created the task model and needed command to run it

class CreateProjectFoldersTask(TaskRQ):
    project = models.ForeignKey(Project, related_name="tasks", null=True, blank=True, on_delete=models.CASCADE)
    job_id = models.CharField(max_length=128)

    TASK_QUEUE = settings.QUEUE_DEFAULT
    TASK_TIMEOUT = 5 * 60
    LOG_TO_FIELD = True
    LOG_TO_FILE = False
    DEFAULT_VERBOSITY = 3

    @staticmethod
    def get_jobclass():
        from core.jobs import CreateUpdateNCGroupFolders
        return CreateUpdateNCGroupFolders

class CreateProjectFoldersCommand(TaskCommand):
    def handle(self, *args, **options):
        self.run_task(CreateProjectFoldersTask, **options)

  • created the job to be executed by the task
class CreateUpdateNCGroupFolders(Job):
    @staticmethod
    def execute(job, task):
        # my job code is running fine here
  • Now i need to get the task id to send it to front end in order to check for the task progress ???
  • even if i put a running task id in JavaScript, to check the functionality it returns

"Reverse for 'core_createprojectfolderstask_viewlogtext' not found. 'core_createprojectfolderstask_viewlogtext' is not a valid view function or pattern name."

  • i tried to call what i did see the view function is doing
task = CreateProjectFoldersTask.objects.first()
task.as_dict()

# it raises this error
File ~/000.WORK/ASES/.venv/lib/python3.8/site-packages/django/urls/resolvers.py:828, in URLResolver._reverse_with_prefix(self, lookup_view, _prefix, *args, **kwargs)
    823 else:
    824     msg = (
    825         "Reverse for '%(view)s' not found. '%(view)s' is not "
    826         "a valid view function or pattern name." % {"view": lookup_view_s}
    827     )
--> 828 raise NoReverseMatch(msg)

NoReverseMatch: Reverse for 'core_createprojectfolderstask_viewlogtext' not found. 'core_createprojectfolderstask_viewlogtext' is not a valid view function or pattern name.

any idea where i missed ?

engragy avatar Oct 09 '23 10:10 engragy