You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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+S to 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:13:01