PyCharm 2023.3: Feature Spotlight for Django Developers
PyCharm 2023.3 introduces a plethora of features for Django development: Django Structure tool window, Live preview for Django templates, enhancements in code assistance for the Django REST framework, and more! This release is poised to enhance the productivity of developers working with Django.
Let’s delve into these functionalities.
Django Structure Tool Window
The Django Structure tool window facilitates prompt and efficient means to create, refactor, and navigate through the main components of your Django project.
The Django Structure tool lists the following components:
- Django Admins
The Django Structure tool window lets you perform the following operations with models:
- Add new models to apps
- Register models in the admin interface
- Navigate to models from model admin classes
- Refactor models
- Find usages of models within the project
By default, the components in the Django Structure tool window are grouped by apps. To group them by component type, click on View Options in the toolbar and select Components.
To go to a component, double-click it. The containing file is opened in the editor, and the caret is set to the corresponding class declaration or function definition.
You can now connect your models to Django Admin effortlessly: select Register in Django Admin option from the context menu, and that’s it!
Another new way to register a Django model is by using Show Context Actions; we will revisit this later.
Generate a view
One click is all it takes! You’ve successfully generated a Django view. It’s truly that straightforward!
Add new models
This action is available only when the components in the tool window are grouped by apps.
Executing database-level commands, such as
migrate, is now simpler. Select the required option from the context menu, and PyCharm will open the manage.py utility with the selected command already entered.
There is an alternative approach to accessing manage.py via the terminal.
Refactor a view
All the comforts of PyCharm refactoring are now available even without opening a file where the view is located.
Live preview for Django templates
PyCharm enables you to operate a built-in browser directly within the integrated development environment (IDE), eliminating the need to navigate away.
Upon opening a template in the editor, the preview is displayed automatically.
* Note: The preview is available only if the template is located in a directory marked as a template folder.
The Live Preview tool window allows you to preview Django templates as you edit them.
You can navigate effortlessly forward or backward within the browser.
The default configuration has the editor and the preview arranged in a vertical split (side by side), catering to wide monitors. Alternatively, you have the option to split them horizontally, positioning the preview in the lower section of the editor—ideal for portrait displays.
Register models with Alt+Enter
This is an alternative method for registering models in Django Admin without leaving the
Right-click a model, select a new intention action, Register in Django admin, and PyCharm will create a
admin.py file (if there isn’t already one in the project) and register the model there. Liberate yourself from the days of typing in model names manually! Utilize this method to register as many models as you need in the Django admin effortlessly.
Auto update of the INSTALLED_APPS
Generate a Django App, and PyCharm will automatically add it to the
Code Assistance for the Django REST Framework
- Code completion in
REST_FRAMEWORKparameters, such as class names and methods.
- Code completion, refactoring, and navigation for
ModelSerializerclass. This applies to the fields of the model assigned to the
- Renaming of the associated getter when refactoring
- Code completion, navigation, and rename refactoring for the methods used in the viewsets.
Full Line Code Completion
PyCharm 2023.3 is equipped with the new local Full Line completion option, which leverages a deep learning model. This feature not only provides full-line completion suggestions but also ensures their correctness. Enjoy faster coding keeping your codebase private.
This represents only a fraction of what’s in store! PyCharm 2023.3 is filled with a multitude of features, including enhancements to the AI Assistant, frontend, diff viewer, and visualizations.
Check out the video below 👇 where our esteemed Developer Advocate, Helen Scott, provides comprehensive coverage of everything you need to know about the latest release.
Subscribe to Blog updates
Livestream: “Python, Django, PyCharm, and More”
Join us for the new PyCharm Livestream episode to learn about everything new in the world of Python on January 25 at 4:00 pm UTC.
How to Connect Django With MongoDB
Learn how to use Django and MongoDB together to create a web application in PyCharm. Follow our step-by-step tutorial to connect MongoDB with Django.
Django vs FastAPI: Which is the Best Python Web Framework?
Introduction If you’re new to web development and have only recently heard of “Frameworks” as a method of speeding up your application development, then you’re in the right place. Today, we’ll explore the two most popular web frameworks in the Python ecosystem currently, namely Django and FastAPI…
Join the Private Preview of Our New Tool for Your ML Experiments!
Join a private preview of our brand-new tool for ML experiments. It lets you set up and launch an experiment from local code on a VM in the cloud directly from PyCharm. We’re granting free access for cloud resources during the preview!