I've got a Django application with djongo
as a database driver. The models are:
class Blog(models.Model):
_id = models.ObjectIdField()
name = models.CharField(max_length=100, db_column="Name")
tagline = models.TextField()
class Entry(models.Model):
_id = models.ObjectIdField()
blog = models.EmbeddedField(
model_container=Blog
)
When I run this application, I got an error:
File "\.venv\lib\site-packages\djongo\models\fields.py", line 125, in _validate_container
raise ValidationError(
django.core.exceptions.ValidationError: ['Field "m.Blog.name" of model container:"<class \'project.m.models.Blog\'>" cannot be named as "name", different from column name "Name"']
I want to keep the name of the field name
in my model and database different because the database already exists, and I can't change it. The database uses camelCase for naming fields, whereas in the application, I want to use snake_case.
How to avoid this error?