[Answered ]-Djongo Company with ID “None” doesn’t exist. Perhaps it was deleted?

1👍

The manual setting of the _id field solved the issue.

from djongo import models

# Create your models here.
class Company(models.Model):
    _id = models.ObjectIdField()
    name = models.CharField(max_length=100, blank=False, null=False, unique=True)
👤vadtam

0👍

This is how I had solved it. Add a UUIDField to your model and set it as primary key.

import uuid


id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=100, blank=False, null=False)

Note: If you already have some objects in the admin panel of this model, then opening that object will still show the same error. It will come to effect only after you make these changes, perform the migrations and add a new object.Then while opening the newly added object you can’t see the error.

👤Ajdal

Leave a comment