Skip to main content

Try autocomplete and source editing

Try autocomplete and source editing (dark theme)
Try autocomplete and source editing (light theme)

Drag the divider or use the arrow keys to compare themes.

Try autocomplete and source editing
Try autocomplete and source editing (dark theme)
Try autocomplete and source editing (light theme)

Drag the divider or use the arrow keys to compare themes.

  1. The category uses the related ModelAdmin search with keyboard navigation.
  2. The server receives a number for the throughput field.
  3. CodeEditor shows the source text and its syntax highlighting.
Try autocomplete and source editing

Django Chassis 1.0.23 · training site with Russian UI

  1. The category uses the related ModelAdmin search with keyboard navigation.
  2. The server receives a number for the throughput field.
  3. CodeEditor shows the source text and its syntax highlighting.

How to add it​

Add EntityPickerOption and the widget override in catalog_demo/admins/device_admin.py. The related CategoryAdmin in catalog_demo/admins/category_admin.py must support searching by name and be registered on the same site.

from django.contrib.admin import ModelAdmin
from django_chassis.mixins import ChassisAdminMixin
from django_chassis.options import EntityPickerOption, SearchOption
from django_chassis.widgets import CodeEditor, UnitInput

class CategoryAdmin(ChassisAdminMixin, ModelAdmin):
options = [SearchOption(fields=['name'])]

class DeviceAdmin(ChassisAdminMixin, ModelAdmin):
options = [EntityPickerOption(fields=['category'])]

def formfield_for_dbfield(self, db_field, request, **kwargs):
if db_field.name == 'settings':
kwargs['widget'] = CodeEditor('json', attrs={'rows': 5})
elif db_field.name == 'capacity':
kwargs['widget'] = UnitInput('операций/мин')
return super().formfield_for_dbfield(db_field, request, **kwargs)

On the change form, type part of a category name and select a match. UnitInput adds a suffix while the Django field continues to parse a number.