0

Could anybody share how and where does Django store the mapping between datatypes like number, string, boolean and UI components like textfield, datepicker, radio button, checkbox etc.

I am trying to build a Django-like admin UI for a Spring-boot application. One of the parts is to create a mapping between datatypes and UI components.

Also, I believe we must have a tag django-internals on Stackoverflow.

comiventor
  • 3,922
  • 5
  • 50
  • 77

2 Answers2

0

Following seems to be one of the places where Django does the datatype to UI component mapping

https://github.com/django/django/blob/master/django/forms/fields.py

comiventor
  • 3,922
  • 5
  • 50
  • 77
0

Python is not Java, and Django is not Spring. Django doesn't think in terms of UI types, and doesn't store mappings.

To interact with data in Django, you create a form. ModelForms know how to create a set of form fields for each field in the model. They do this by calling the formfield method of each model field.

Each form field, in turn, is associated with a default widget, which determines how that field is displayed in a form.

Both field and widget can be overridden in the form definition.

(Note this is not a "Django internal", but the documented way to use the framework.)

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895