This readme is designed to make your Django development (assuming with VSCode) a bit simpler and faster. It contains useful setup instructions, extensions, and settings to help optimize your workflow. Feel free to use the table of contents below to jump around. 🤠
Please let me know (open an issue, post on piazza, or email me at [email protected]) if you have any questions or suggestions for things to add!
Table of Contents
By default, VSCode my not assign the correct Python interpreter when opening your Django folder.
- you must run
pipenv shellevery time you re-open the project in order to use Django-related commands - Intellisense will not work and your code will likely be covered in warnings since the interpreter cannot recognize Django imports...
-
get pipenv environment path
# cd into your `django` directory cd django # exctract and COPY the path of the virtual environment pipenv --venv
-
update python interpreter in vscode
- on mac: press
cmd+shift+p(on windows: pressctrl+shift+p) - type "Python: Select Intepreter"
- choose "Enter interpreter path..."
- paste the path from pipenv --venv
- on mac: press
You should only have to complete these steps once for you given django project!
This setup is used to configure abbreviations in languages that are not supported by default in VSCode. For you all, the most relevant one is Django-HTML (which is the file type that VSCode automtically recognizes for HTML files loated in your Django projects).
- By default, Emmet does not work in Django-HTML files. This means you won’t be able to use Emmet’s shorthand for expanding HTML elements, which can significantly slow down your workflow, especially when working with templates that contain a lot of HTML.
- Open your VSCode settings (Ctrl + , or Cmd + , on macOS).
- Search for
Emmet: Include Languagesin the settings search bar. - Click on "Add item"go-HTML with HTML:
Below are a list of VSCode extensions that I personally use to make development a bit easier (especially when working with Django-HTML). Feel free to let us know if any are missing!
- Django
- Python
- Auto Rename Tag
- Auto Docstring
- Black Formatter (for Python)
- HTML Boilerplate (really useful for quickly setting up a
base.htmlfile) - HTML CSS Support
- Pylance