Beispiel #1
0
 def save_model(self, request, obj, form, change):
     """在管理后台新增或修改了模型数据后调用"""
     super().save_model(request, obj, form, change)
     print('save_model: %s ' % obj)
     # 通过celery异步生成静态的首页
     generate_static_index_html().delay()
     # generate_static_index_html()
     # 修改了数据库数据就需要删除缓存
     cache.delete('index_page_data')
Beispiel #2
0
    def delete_model(self, request, obj):
        """删除表中的数据时调用"""
        super().delete_model(request, obj)
        # 发出任务,让celery worker 重新生成首页静态页
        from celery_tasks.tasks import generate_static_index_html
        generate_static_index_html()

        # 清除首页的缓存数据
        cache.delete('index_page_data')
Beispiel #3
0
    def delete_model(self, request, obj):
        """管理员删除时候更新index页面"""
        super(BaseModelAdmin, self).delete_model(request, obj)

        # 发出任务让celery重新生成静态页面
        from celery_tasks.tasks import generate_static_index_html
        generate_static_index_html()

        # 更新首页的缓存
        cache.delete('index_page_data')
Beispiel #4
0
 def delete_model(self, request, obj):
     """
     删除表中数据时调用
     :param request:
     :param obj:
     :return:
     """
     super().delete_model(request, obj)
     from celery_tasks.tasks import generate_static_index_html
     generate_static_index_html()
Beispiel #5
0
    def save_model(self, request, obj, form, change):
        """新增或更新表中的数据时调用"""
        super().save_model(request, obj, form, change)

        # 发出任务,让celery worker 重新生成首页静态页
        # 为何在顶部导入不可以,执行celery会出错
        from celery_tasks.tasks import generate_static_index_html
        generate_static_index_html()

        # 清除首页的缓存数据
        cache.delete('index_page_data')
Beispiel #6
0
    def save_model(self, request, obj, form, change):
        """
        当促销页被管理员修改时,会触发modelAdmin自动的save_model方法
        在这里需要重新生成index静态文件
        """
        super(BaseModelAdmin, self).save_model(request, obj, form, change)

        # 发出任务让celery重新生成静态页面
        from celery_tasks.tasks import generate_static_index_html
        generate_static_index_html()

        # 更新首页的缓存
        cache.delete('index_page_data')
Beispiel #7
0
from celery_tasks.tasks import generate_static_index_html

generate_static_index_html()
Beispiel #8
0
 def save_model(self, request, obj, form, change):
     super().save_model(request, obj, form, change)
     # 发出任务,让celery worker重新生成首页静态页面
     print(obj)
     from celery_tasks.tasks import generate_static_index_html
     generate_static_index_html()