PyCharm社区版2017中Django项目的CSS创建与Bootstrap自动补全问题求助
Fixing PyCharm Community 2017 Issues on Ubuntu 16.04 for Django Projects
Hey there! Let's work through those two frustrating issues you're hitting with your Django development setup. Here's how to fix each one:
1. Adding CSS File Option to New File Menu
Looks like PyCharm's default templates might be missing the CSS option. No worries—you can add it manually:
- Open PyCharm and hit
Ctrl+Alt+Sto open Settings. - Navigate to Editor > File and Code Templates.
- In the Templates panel, click the small
+icon in the top-left corner to create a new template. - Name it
CSS File, set the file extension to.css, and you can leave the template content blank or add a simple comment like/* Project Stylesheet */if you want. - Click Apply then OK. Next time you right-click to create a new file, you'll see the CSS option in the list.
2. Enabling Bootstrap Auto-Completion
Bootstrap auto-completion needs PyCharm to recognize the framework's files first. Here's how to set that up:
- First, make sure you have Bootstrap's files in your Django project (either downloaded locally and placed in your static directory—local files work better for auto-completion—or linked via CDN).
- Open Settings again (
Ctrl+Alt+S) and go to Languages & Frameworks > Stylesheets > CSS. - Switch to the Frameworks tab, then click the
+button on the right and select Bootstrap from the dropdown. - In the pop-up window, browse to the directory where your local Bootstrap files are stored (if using CDN, download a copy of Bootstrap first and point to that folder).
- Double-check that your HTML templates correctly reference Bootstrap's CSS using Django's static template tag, like:
<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}"> - Restart PyCharm or reload your project, and you should start seeing Bootstrap class names and properties auto-completing as you type.
内容的提问来源于stack exchange,提问作者Stoufa Gheribi
相关产品推荐
相关产品推荐

