def get_blog_setting(): value = cache.get('get_blog_setting') if value: return value else: from blog.models import BlogSettings if not BlogSettings.objects.count(): setting = BlogSettings() setting.sitename = 'DjangoBlog' setting.site_description = 'Blog system based on Django' setting.site_seo_description = 'Blog system based on Django' setting.site_keywords = 'Django,Python' setting.article_sub_length = 300 setting.sidebar_article_count = 10 setting.sidebar_comment_count = 5 setting.show_google_adsense = False setting.open_site_comment = True setting.analyticscode = '' setting.beiancode = '' setting.show_gongan_code = False setting.save() value = BlogSettings.objects.first() logger.info('set cache get_blog_setting') cache.set('get_blog_setting', value) return value
def get_blog_setting(): value = cache.get('get_blog_setting') if value: logger.info('get cache get_blog_setting') return value else: from blog.models import BlogSettings if not BlogSettings.objects.count(): setting = BlogSettings() setting.sitename = 'DjangoBlog' setting.site_description = '基于Django的博客系统' setting.site_seo_description = '基于Django的博客系统' setting.site_keywords = 'Django,Python' setting.article_sub_length = 300 setting.sidebar_article_count = 10 setting.sidebar_comment_count = 5 setting.show_google_adsense = False setting.open_site_comment = True setting.analyticscode = '' setting.beiancode = '' setting.show_gongan_code = False setting.save() value = BlogSettings.objects.first() logger.info('set cache get_blog_setting') cache.set('get_blog_setting', value) return value
def get_blog_setting(): value = cache.get('get_blog_setting') if value: return value else: from blog.models import BlogSettings if not BlogSettings.objects.count(): setting = BlogSettings() setting.sitename = 'agrosite' setting.site_description = 'This is the description of this site' setting.site_seo_description = 'This is the seo description of this site' setting.site_keywords = 'agrosite,farm,agriculture,agrohelp,farmer,vegetables,agroapp' setting.article_sub_length = 200 setting.sidebar_article_count = 10 setting.sidebar_comment_count = 5 setting.show_google_adsense = False setting.open_site_comment = True setting.analyticscode = '' setting.beiancode = '' setting.show_gongan_code = False setting.save() value = BlogSettings.objects.first() logger.info('set cache get_blog_setting') cache.set('get_blog_setting', value) return value
def get_blog_setting(): value = cache.get('get_blog_setting') if 1 == 2 and value: return value else: from blog.models import BlogSettings if not BlogSettings.objects.count(): setting = BlogSettings() setting.sitename = '华泰辉创' setting.site_description = '基于Django的博客系统' setting.site_seo_description = '基于Django的博客系统' setting.site_keywords = 'Django,Python' setting.article_sub_length = 300 setting.sidebar_article_count = 10 setting.sidebar_comment_count = 5 setting.show_google_adsense = False setting.open_site_comment = True setting.analyticscode = '' setting.beiancode = '京ICP备19011312号-1' setting.gongan_beiancode = '' setting.show_gongan_code = False setting.save() value = BlogSettings.objects.first() logger.info('set cache get_blog_setting value={%s}' % value) #cache.set('get_blog_setting', value) return value
def get_blog_setting(): value = cache.get('get_blog_setting') if value: return value else: from blog.models import BlogSettings if not BlogSettings.objects.count(): setting = BlogSettings() setting.sitename = 'jingBlog' setting.site_description = '' setting.site_seo_description = '' setting.site_keywords = 'Django,Python' setting.article_sub_length = 300 setting.sidebar_article_count = 10 setting.sidebar_comment_count = 5 setting.show_google_adsense = False setting.open_site_comment = True setting.analyticscode = '' setting.beiancode = '鄂ICP备2020017327号' setting.show_gongan_code = False setting.save() ## 第一次生产后就定死了 暂时修改为重复辅助 else : setting = BlogSettings() setting.sitename = 'jingBlog' setting.site_description = '' setting.site_seo_description = '' setting.site_keywords = 'Django,Python' setting.article_sub_length = 300 setting.sidebar_article_count = 10 setting.sidebar_comment_count = 5 setting.show_google_adsense = False setting.open_site_comment = True setting.analyticscode = '' setting.beiancode = '鄂ICP备2020017327号' setting.show_gongan_code = False setting.save() inedx = len(BlogSettings.objects.all())-1 value = BlogSettings.objects.all()[inedx] logger.info('set cache get_blog_setting') cache.set('get_blog_setting', value) return value