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?



Read more here: https://stackoverflow.com/questions/65701682/django-models-in-admin-return-typeerror-bad-operand-type-for-unary-str

Content Attribution

This content was originally published by abdul rehman at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: