I am learning celery by following this tutorial .
I created the tasks as he did and tried running the code. But I get the following error
NameError: name 'shared_task' is not defined
This is my code
import requests
from bs4 import BeautifulSoup
import json
from datetime import datetime
import lxml
@shared_task
def scrape():
try:
...
This code is working for him but I get the above mentioned error. Not sure what I am doing wrong. Please help me
Thanks in advance
You need to import the celery shared_task
decorator as
def scrape():
...
# your code
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.