how are you all?
We are not able to insert the fixures data into our SQLite3 database.
We are using UUid as our model id.
Using the comand python.exe .\manage.py loaddata start.json
Model
class Estadual(models.Model):
# Fields
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
estado = models.CharField(max_length=50)
sigla = models.CharField(max_length=2, unique=True)
valor = models.PositiveSmallIntegerField()
created = models.DateTimeField(auto_now_add=True, editable=False)
last_updated = models.DateTimeField(auto_now=True, editable=False)
# Relationships
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
class Meta:
pass
start.json
[
{
"model": "app.estadual",
"pk": "59472bb0-7f6e-4026-a900-727b7cdd647f",
"fields": {
"estado": "AC",
"sigla": "AC",
"valor": 12,
"user": ["4a695e40-6b3a-49fa-8beb-eed853ce17b0"]
}
},{
"model": "app.estadual",
"pk": "5b321ca7-e8be-4580-8d36-080c663d5397",
"fields": {
"estado": "AL",
"sigla": "AL",
"valor": 12,
"user": ["4a695e40-6b3a-49fa-8beb-eed853ce17b0"]
}
}
]
Error
Problem installing fixture 'C:...fixtures\start.json': Could not load app.Estadual(pk=59472bb0-7f6e-4026-a900-727b7cdd647f): NOT NULL constraint failed: app_estadual.created