Search code examples
pythondjangodjango-modelsdjango-admin

Django admin integer field with '+' '-' on either side to increment/decrement value


Im stuck in a client's requirement. He wants to have a field in django admin panel like the screenshot I have attached screenshot

I have a field in my model landing_page_btn_text_size = models.CharField(verbose_name=_("Button Text Size"), max_length=255, default="20px")

Now he want if i click '-' it subtracts 1 from the value and if '+' it adds 1 to the value.

Any help would be appreciated, thanks.


Solution

  • Django automatically includes this on an IntegerField. One way to include this, is to add in px to the verbose_name and change the model it to an IntegerField.