'Django models in admin return TypeError: bad operand type for unary -: 'str'

I'm working on a project using Django(3) and Python(3) in which I have added few models and added those models in admin.py, but when I open the admin panel and try to add an object for those models it returns an error.

Here's one of my model which is returning error:

From models.py:

class CurrencyManagementAssetsModel(models.Model):
    RequestId = models.IntegerField(blank=False)
    CbnInstitutionCode = models.CharField(max_length=5, blank=False)
    SortCode = models.CharField(max_length=10, blank=False)
    Count = models.IntegerField(blank=False)
    AssetClassificationId = models.IntegerField(blank=False)
    AssetTypeId = models.IntegerField(blank=False)
    ValueOfCurrencyDistributed = models.DecimalField(max_digits='20', decimal_places='10', 
    blank=False)
    VaultCapacity = models.DecimalField(max_digits='20', decimal_places='10', blank=False)
    Year = models.IntegerField(blank=False)
    HalfOftheYear = models.IntegerField(blank=False)

    class Meta:
        verbose_name = 'Currency Management Assets'

From admin.py:

from django.contrib import admin
from .models import CurrencyManagementAssetsModel

admin.site.register(CurrencyManagementAssetsModel)

and Here's the error I'm getting when click on that particular model in admin:

Request Method: GET Request URL: http://127.0.0.1:8000/admin/reports/currencymanagementassetsmodel/ Django Version: 3.1.3 Exception Type: TypeError Exception Value: bad operand type for unary -: 'str'

What can be wrong here?



Solution 1:[1]

Django automatically inserts null values to fields which have blank =True. So to correct your error specify null=True in that field since the field is integer field instead of char field. please sorry I made a mistake, please remove blank = false from your models fields because the blank PARAM is false by default.

Solution 2:[2]

reason of the error

decimal_places='10'
max_digits='20'

it should be

decimal_places=10
max_digits=20

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 umair mehmood