Comments (2)
Hi @fortunto2
Feel free to ignore if you already solved the issue, but I'm leaving the reference in case someone ends up here in the future.
By default, ODMantic generates an id
field itself for every Model. You can see the details here on why it does that.. This is the reason why you're getting an error: ODMantic is trying generate an implicit id
field for your Catalog model but it already exists (i.e. defined by you in the model).
To use the id
field (or, really, any name for the field you want your primary field to be), you have to do this:
from odmantic import Field, Model
class Catalog(Model):
id: str = Field(primary_field=True)
parent: Optional[str]
from odmantic.
@adeelsohailahmed cool, thank you!
from odmantic.
Related Issues (20)
- Can't start dev container: multi-python is deprecated
- Optional EmbeddedModel not working HOT 3
- Just started following tutorial in https://art049.github.io/odmantic/ and an error HOT 3
- Any specific reason to not support model inheritance?
- `Optional[str]` triggers `int_parsing` instead of string parsing when used for `odmantic.Model` HOT 4
- Multiple sorting criteria HOT 1
- Mypy issues for odmantic 1.0.0 HOT 2
- Trying to use db_engine.configure_database([User]) HOT 1
- Support Inheritance
- regex is removed in pydantic 2.x this causes the Field class to throw an exception if its used. HOT 1
- Support for Optional types as X | None HOT 1
- Embedded models have to be defined before any normal models that reference them HOT 4
- Question: how to mock/write propper unittests HOT 2
- when a model has many optional field, it will raise unwanted validation type error HOT 4
- Odmantic Does Not Add Pydantic Computed Fields to MongoDB HOT 1
- Aggregation support via the find method HOT 1
- Datetime not updating and not updating frequently
- Injected Context for Model Class not picked up
- Unexpected @field_validator behaviour
- ODMantic is incompatible with pydantic version 2.7.0 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from odmantic.