遍历修改djangobootstrapform为djangobootstrap3
#!/usr/bin/env python # encoding: utf-8 import re import os fname = '' bt_pattern = re.compile(r'{% load bootstrap .*') field_pattern = re.compile(r'(\s*){{\s*(form\.\w+)\|\s*bootstrap_horizontal\s*}} *') def bs2bs3(fn): with open(fn) as f: content = f.read() content = bt_pattern.sub(r'{% load bootstrap3 %}', content) content = field_pattern.sub(r'\1{% bootstrap_field \2 layout="horizontal" %}', content) with open(fn, 'w') as f: f.write(content) def walk_dir(dirname): for root, dirs, files in os.walk(dirname, topdown=False): for name in files: fname = os.path.join(root, name) bs2bs3(fname)
原文链接:https://www.cnblogs.com/cmsd/p/6680401.html
本文来源 爱码网,其版权均为 原网址 所有 与本站无关,文章内容系作者个人观点,不代表 本站 对观点赞同或支持。如需转载,请注明文章来源。
© 版权声明
文章版权归作者所有,未经允许请勿转载。