Django Developers Guild hosted its first online event on 28 January 2023 and discussed some important topics related to the Django framework. Here's a summary of the key takeaways from the event.
Django has become a popular framework for web development due to its speed of development, great community, and proven track record of performance and scalability.
VirtualEnvWrapper is much more beginner friendly when compared to other virtual environment tools, as it maintains all files in a separate location outside the project folder. Refer to this step-by-step guide to install virtualenvwrapper.
The solution involves two steps – installing the python extension pack and configuring the python interpreter.
1️⃣ Python extension pack: Locate the extensions' icon in your VS Code sidebar and search for "Python".
Locate the extension pack by Microsoft containing Jupyter, isort and Pylance extensions, and install it.
Reload VS Code if required.
2️⃣ Configure python interpreter
Find the virtual environment's python path.
Update VS Code's python interpreter.
Fix indentation errors by using the black formatter.
1️⃣ Install black.
pip install black
2️⃣ Configure Python formatter
Go to Settings, search for "python formatting provider" and select "Black".
Configure VS Code to automatically add new lines at the end of files upon saving.
Configure VS Code to automatically remove whitespaces at the end of lines upon saving.
Pytest is a better alternative to python's built-in unit testing library. It is compact (takes fewer lines to write), faster and provides a better way to organise test data through fixtures.
Use data migrations when you need to add/remove rows across all environments – alpha, beta, staging and production. For example, pricing plans on a website (say GOLD, SILVER and PLATINUM).
Use fixtures (prefer YAML) when you must load consistent test data across testing environments (but not production). For example, test user accounts.
A few other extensions that Django developers might find useful.
If you found this article helpful, please share it with your friends. Our next edition of the Django Developers Guild meeting will happen on Saturday, 18 February 2023.