Welcome | Get started | Dive into Lino | Contribute | Topics | Reference | More

Fields with an input mask

This document describes and tests the mask_re option of a lino.core.fields.CharField.

We define a single model:

from django.db import models
from lino.api import dd


class Foo(dd.Model):

    name = models.CharField(max_length=100, blank=True)
    remarks = models.TextField("Remarks", blank=True)
    input_mask_test = dd.CharField(
        "Input mask test",
        blank=True,
        max_length=200,
        help_text="""This field is here to play with the
        CharField parameters regex, mask_re and strip_chars_re.
        By default it accepts all letters except Z.
        """,
        #~ regex='/^[a-yA-Y]*$/')
        mask_re='/^[a-yA-Y]*$/')
    #~ strip_chars_re='/^[a-yA-Y]*$/')


class Foos(dd.Table):
    model = Foo

    column_names = 'name input_mask_test id remarks'

    detail_layout = """
    id name input_mask_test
    remarks
    """

    insert_layout = """
    name
    input_mask_test
    """

This field is here to play with the CharField parameters regex, mask_re and strip_chars_re. By default it accepts all letters except Z.

How to try this:

$ cd docs/tutorials/input_mask
$ pm prep
$ pm runserver
  • No need to sign in since this app has no users.

  • Select Input Mask ‣ foos in the main menu

  • Click the insert button

  • Try to enter "Zoro" in the field Input mask test