I have added a new model to my admin. This is my models.py:
class EngineeringToolAttributeType(models.Model):
name = models.CharField(max_length=50)
description = models.CharField(max_length=255, blank=True, null=True)
api_url = models.CharField(max_length=255, blank=True, null=True)
api_field = models.CharField(max_length=50, blank=True, null=True)
active = models.BooleanField(default=True)
def __str__(self):
return self.name
And the admin.py:
from extras.models import EngineeringToolAttributeType
from django.contrib import admin
class EngineeringToolAttributeTypeAdmin(admin.ModelAdmin):
fields = ['name', 'description', 'api_url', 'api_field', 'active']
list_display = ('name', 'description', 'api_url', 'api_field', 'active')
admin.site.register(EngineeringToolAttributeType, EngineeringToolAttributeTypeAdmin)
When I try to add (click on add button via the admin), I get this error:
Internal Server Error: /website/admin/extras/engineeringtoolattributetype/add/
IntegrityError at /admin/extras/engineeringtoolattributetype/add/
null value in column "name" violates not-null constraint
This has never happened before. I know name is not allowed to be Null
, but I'm still adding a record. How is that possible?