| 123456789101112131415161718192021222324252627 |
- from app import create_app, db
- from app.models import PageContent
- app = create_app()
- with app.app_context():
- db.create_all()
-
- defaults = [
- {'key': 'products', 'name': '产品', 'content': '<p>暂无内容,请在后台添加</p>'},
- {'key': 'solutions', 'name': '解决方案', 'content': '<p>暂无内容,请在后台添加</p>'},
- {'key': 'education', 'name': '产教融合', 'content': '<p>暂无内容,请在后台添加</p>'},
- {'key': 'service', 'name': '产业服务', 'content': '<p>暂无内容,请在后台添加</p>'}
- ]
-
- for item in defaults:
- existing = PageContent.query.filter_by(page_key=item['key']).first()
- if not existing:
- new_page = PageContent(
- page_key=item['key'],
- page_name=item['name'],
- content=item['content']
- )
- db.session.add(new_page)
-
- db.session.commit()
- print("Page contents initialized successfully.")
|