News Python Web Development

PyCharm 2023.3: Feature Spotlight for Django Developers

PyCharm 2023.3 introduces a plethora of features for Django developmentDjango 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.

Try PyCharm for Django

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
  • Models
  • Views

The Django Structure tool window lets you perform the following operations with models:

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.

Register models

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.

Manage.py actions

Executing database-level commands, such as makemigrations and 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 browser comes equipped with a robust set of developer tools. These tools serve various purposes, ranging from inspecting currently displayed HTML, CSS, and JavaScript to revealing the assets the page has requested and their respective loading times.

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 models.py file.

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 INSTALLED_APPS list.

Code Assistance for the Django REST Framework

  1. Code completion in settings.py file for REST_FRAMEWORK parameters, such as class names and methods.
  1. Code completion, refactoring, and navigation for fields, extra_kwargs, read_only_fields, and exclude within the ModelSerializer class. This applies to the fields of the model assigned to the ModelSerializer.
  1. Renaming of the associated getter when refactoring SerializerMethodField.
  1. 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.

Try PyCharm for Django

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.

image description