0

I have the below model:

class Loan(models.Model):
    id = models.BigAutoField(primary_key=True)
    date = models.DateField(default=timezone.now)
    description = models.TextField(max_length=255)

When I try to save date and description I get the above error

enter image description here

below is my admin.py file:

@admin.register(Loan)
class LoanAdmin(admin.ModelAdmin):
      pass

and below is my table created through migrations:

enter image description here

Django 3.2.6. How can I solve this?

SQL Server version is Microsoft SQL Server 2019 (RTM-CU8-GDR)

I tried :

class Loan(models.Model):
    date = models.DateField(default=timezone.now)
    description = models.TextField(max_length=255)
lewis machilika
  • 819
  • 2
  • 11
  • 25

2 Answers2

1

The solution that worked to this problem was to delete all migrations and create new migrations.

lewis machilika
  • 819
  • 2
  • 11
  • 25
0

you don't need to add id column specifically. Django creates id column itself.

class Loan(models.Model):
    date = models.DateField(default=timezone.now)
    description = models.TextField(max_length=255)

This should work. Also, if you want to add custom id column check this