diff --git a/docs/reference/contrib/modeladmin.rst b/docs/reference/contrib/modeladmin.rst index de6773fef9..8cba0556f7 100644 --- a/docs/reference/contrib/modeladmin.rst +++ b/docs/reference/contrib/modeladmin.rst @@ -218,3 +218,47 @@ methods), giving you lots of flexibility when it comes to output. giving your users an easy way to find what they're looking for. `Read more about list_filter in the Django docs `_. + +Customizing the layout +---------------------- + +``edit_handler`` can be used on any Django models.Model classes just like it can be used on ``Page`` classes. + +To change the way your ``MyPageModel`` is displayed in the CreateView and the EditView, simply define an ``edit_handler`` or ``panels`` in your model. + +.. code-block:: python + + class MyPageModel(models.Model): + first_name = models.CharField(max_length=100) + last_name = models.CharField(max_length=100) + address = models.TextField() + + panels = [ + MultiFieldPanel([ + FieldRowPanel([ + FieldPanel('first_name', classname='fn'), + FieldPanel('last_name', classname='ln'), + ]), + FieldPanel('address', classname='custom1',)) + ] + +Or alternatively: + +.. code-block:: python + + class MyPageModel(models.Model): + first_name = models.CharField(max_length=100) + last_name = models.CharField(max_length=100) + address = models.TextField() + + custom_panels = [ + MultiFieldPanel([ + FieldRowPanel([ + FieldPanel('first_name', classname='fn'), + FieldPanel('last_name', classname='ln'), + ]), + FieldPanel('address', classname='custom1',)) + ] + edit_handler = ObjectList(custom_panels) + # or + edit_handler = TabbedInterface([ObjectList(custom_panels), ObjectList(...)])