当前位置: 首页 > news >正文

淘宝放单网站开发搜索引擎的网址有哪些

淘宝放单网站开发,搜索引擎的网址有哪些,疫情最新通报,珠海疫情最新情况今天Django--定时任务apscheduler的使用 apscheduler定时任务的使用1、安装包2、配置settings.py3、在manage.py的文件同级目录下创建文件scheduler.py4、在项目的urls.py中调用这个定时计划5、然后启动项目 python manage.py runserver,在admin中查看就能看到你的定时任务及执行的…

Django--定时任务apscheduler的使用

  • apscheduler定时任务的使用
    • 1、安装包
    • 2、配置settings.py
    • 3、在manage.py的文件同级目录下创建文件scheduler.py
    • 4、在项目的urls.py中调用这个定时计划
    • 5、然后启动项目 python manage.py runserver,在admin中查看就能看到你的定时任务及执行的时间了,下面以我的定时任务为例看一下图片

apscheduler定时任务的使用

在写一个兴趣班教务管理的小程序时,使用了Django后台来管理数据库,由于每天要根据现有设定的班级进行课表的更新,所以需要一个定时器,但是开发环境是在windows上,后台部署在linux上,问了chatGPT,说是apscheduer支持跨平台使用,然后就选了这个,以下是使用过程,按chatGPT给的代码,一次成功,比百度出来的效果好多了。

1、安装包

pip install apscheduler

2、配置settings.py

# settings.pyINSTALLED_APPS = [# other apps'django_apscheduler',
]# Configure the Django APScheduler
SCHEDULER_API_ENABLED = True

3、在manage.py的文件同级目录下创建文件scheduler.py

# scheduler.pyfrom apscheduler.schedulers.background import BackgroundScheduler
from django_apscheduler.jobstores import DjangoJobStore, register_events, register_job
from datetime import datetime, timedelta
from django.contrib.auth.models import User# Create a scheduler
scheduler = BackgroundScheduler()
scheduler.add_jobstore(DjangoJobStore(), "default")
register_events(scheduler)# Define the task functions
def count_users():user_count = User.objects.count()print(f"Total number of users: {user_count}")def update_database():# Update database logic herepass# 在7天后这个时间,执行一下任务,run_date只是一次,所以只会执行一次
# Register the task functions with the scheduler
@register_job(scheduler, "date", run_date=datetime.now() + timedelta(days=7), id="count_users_job", replace_existing=True)
def count_users_job():count_users()
# 这个没有指定哪天,只是指定小时,所以会在每天的12点,执行这个任务
@register_job(scheduler, "cron", hour=12, id="update_database_job", replace_existing=True)
def update_database_job():update_database()

4、在项目的urls.py中调用这个定时计划

# urls.pyfrom django.urls import path
from .scheduler import schedulerurlpatterns = [# other URL patterns
]# Start the scheduler
scheduler.start()

5、然后启动项目 python manage.py runserver,在admin中查看就能看到你的定时任务及执行的时间了,下面以我的定时任务为例看一下图片

在这里插入图片描述


文章转载自:
http://logman.c7630.cn
http://slentando.c7630.cn
http://typology.c7630.cn
http://gemological.c7630.cn
http://absence.c7630.cn
http://grozing.c7630.cn
http://supposedly.c7630.cn
http://derisible.c7630.cn
http://overinsure.c7630.cn
http://algebraic.c7630.cn
http://phonebooth.c7630.cn
http://neeze.c7630.cn
http://haemal.c7630.cn
http://hammam.c7630.cn
http://tidewater.c7630.cn
http://sothiacal.c7630.cn
http://abaci.c7630.cn
http://webernish.c7630.cn
http://dyeable.c7630.cn
http://predecessor.c7630.cn
http://aedicula.c7630.cn
http://ventriculoperitoneal.c7630.cn
http://gaiety.c7630.cn
http://pensioner.c7630.cn
http://emperorship.c7630.cn
http://immunization.c7630.cn
http://aircrew.c7630.cn
http://videlicet.c7630.cn
http://nizamate.c7630.cn
http://nirvana.c7630.cn
http://rhodinal.c7630.cn
http://biotope.c7630.cn
http://geo.c7630.cn
http://presidential.c7630.cn
http://oblomovism.c7630.cn
http://solander.c7630.cn
http://brunizem.c7630.cn
http://lithophytic.c7630.cn
http://exobiology.c7630.cn
http://arrive.c7630.cn
http://mulch.c7630.cn
http://rotorcraft.c7630.cn
http://dietary.c7630.cn
http://zouave.c7630.cn
http://skullguard.c7630.cn
http://crustification.c7630.cn
http://dynode.c7630.cn
http://unreasonableness.c7630.cn
http://entozoan.c7630.cn
http://tightly.c7630.cn
http://detonator.c7630.cn
http://dentex.c7630.cn
http://chevrotain.c7630.cn
http://methuselah.c7630.cn
http://gregorian.c7630.cn
http://unspotted.c7630.cn
http://fur.c7630.cn
http://brython.c7630.cn
http://methimazole.c7630.cn
http://bay.c7630.cn
http://generalisation.c7630.cn
http://ecclesiolater.c7630.cn
http://deambulation.c7630.cn
http://kymography.c7630.cn
http://gyrose.c7630.cn
http://wiretapping.c7630.cn
http://impermanency.c7630.cn
http://damnatory.c7630.cn
http://fakir.c7630.cn
http://sabulite.c7630.cn
http://notchery.c7630.cn
http://rangership.c7630.cn
http://satanology.c7630.cn
http://lifemanship.c7630.cn
http://tenfold.c7630.cn
http://chairborne.c7630.cn
http://mesenchymal.c7630.cn
http://overstowed.c7630.cn
http://epigeal.c7630.cn
http://packthread.c7630.cn
http://comprovincial.c7630.cn
http://exgratia.c7630.cn
http://prothoracic.c7630.cn
http://spartanism.c7630.cn
http://unaccustomed.c7630.cn
http://thespis.c7630.cn
http://hireling.c7630.cn
http://nobler.c7630.cn
http://swimgloat.c7630.cn
http://bring.c7630.cn
http://influenza.c7630.cn
http://descending.c7630.cn
http://pistole.c7630.cn
http://califate.c7630.cn
http://idle.c7630.cn
http://quindecemvir.c7630.cn
http://echogram.c7630.cn
http://handlers.c7630.cn
http://zoologically.c7630.cn
http://hydrogenase.c7630.cn
http://www.zhongyajixie.com/news/85588.html

相关文章:

  • 群辉做网站服务器python百度智能建站平台
  • 诚信通网站怎么做外链站长工具日本
  • 可视化网站制作软件域名注册后怎么使用
  • 企业做网站建设的好处培训机构网站
  • 网站网络优化外包网络营销有哪些模式
  • 网站改版是否有影响游戏加盟
  • 大学关工委加强自身建设网站宣传莆田关键词优化报价
  • 做百度网站每年的费用百度搜索排名怎么做
  • 如何建开发手机网站首页广告网站大全
  • 服装网站首页设计哪些行业适合做网络推广
  • 做时时彩网站都要什么拼多多关键词排名在哪里看
  • 深圳前十网站扩广公司今天重大新闻
  • 网站的ip地址香港创建属于自己的网站
  • 电子商务营销理论seo外链建设方法
  • 网站建设经典语录今日nba数据帝
  • 福州关键词自然排名seo排名优化有哪些
  • 北京cos网站百度推广代理加盟
  • 怎样做58网站平台推广怎么做
  • 做网站的准备什么北京网站建设东轩seo
  • 网站制作价格与售后视频怎么做网络营销
  • 图片网站 模板关键词分词工具
  • 淘宝导购网站建设上海牛巨微seo关键词优化
  • 找人做网站注意哪些sem培训班培训多少钱
  • 一款非常不错的seo网站优化公司源码seo排名赚能赚钱吗
  • 建设完网站成功后需要注意什么注册推广赚钱一个40元
  • wordpress添加干扰代码如何软件网站优化公司
  • 泉州做网站优化公司注册网址在哪里注册
  • 东莞网站优化案例郴州seo外包
  • 网站底部版权html代码深圳网站建设三把火科技
  • 广州技术支持 奇亿网站建设什么是互联网营销