A
A
AinzO2021-08-16 10:39:22
Django
AinzO, 2021-08-16 10:39:22

How to make it so that when entering into a specific field of the database there is a selection of answers (for example, you could enter either + or -)?

For example, to allow only "+" or "-" to be entered in the workwithtenagers field when entering through the admin panel, it is desirable that a tooltip appear.

class WorkingBase(models.Model):
  title = models.CharField('Наименование', max_length=220)
  workwithtenagers = models.CharField('Работают с подростками?', max_length=220)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Nesterov, 2021-08-16
@AinzO

Either via BooleanField or with choices (you can specify more than two values)

class Author(models.Model):
    gender_choises = (
        ('F', 'Женщина'),
        ('M', 'Мужчина')
    )
    ...
    gender = models.CharField(verbose_name='Пол', choices=gender_choises,max_length=8)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question