I added a new model for my admin. These are 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 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 the add button through 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 that the name cannot be Null , but I am adding an entry anyway. How is this possible?
Ruben source share