D
D
Daniil Chernov2020-09-16 12:11:43
Django
Daniil Chernov, 2020-09-16 12:11:43

How to show or hide input field in django admin?

For example, there is a model:

spoiler

class Receipt(models.Model):
    sum = models.FloatField(verbose_name='Сумма')
    com = models.TextField(verbose_name='Коментарий', blank=True, null=True)
    type = models.CharField(max_length=2, choices=MONEY, default=CASH, verbose_name='Вид движения средств')
    date = models.DateField(default=timezone.now, verbose_name='Дата прихода')
    category = models.ForeignKey(CategoriesOfReceipt, on_delete=models.DO_NOTHING, verbose_name='Категория')
    deal = models.ForeignKey(Affairs, on_delete=models.DO_NOTHING, verbose_name='Дело', blank=True, null=True)



In the admin panel, respectively, all fields are visible.
How to make the field "deal" not visible. And when you select a certain "category", "deal" was shown?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-09-16
@bacon

Since this is on the client, you will have to write code in js, the usual work with the DOM and events.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question