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)
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.
- [Answered ]-Unable to import view in Django project
- [Answered ]-Storing subprocess object in memory using global singleton instance
- [Answered ]-How to set 2 rows to become header in a dataframe with originally has a header?
- [Answered ]-Django backend wont accept get requests from my front end
- [Answered ]-Django-admin: cant access admin backend "attempt to write a readonly database"
Source:stackexchange.com