-
-
Notifications
You must be signed in to change notification settings - Fork 392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'exclude_readonly' is ignored when the 'name' argument isn't used in pydantic_model_creator #594
Comments
+1 here, couldn't figure out what I was doing wrong until I stumbled on this. My configuration: base.py
note.py
Leaving the names off of the pydantic models results in the |
I have a same issue。 class BaseModel(models.Model):
created_at = fields.DatetimeField(auto_now_add=True, description='创建时间')
updated_at = fields.DatetimeField(auto_now=True, description='修改时间')
class Meta:
abstract = True
class Meta(BaseModel):
id = fields.IntField(pk=True)
custom_id = fields.CharField(max_length=128, description='自定义ID')
user: fields.ForeignKeyRelation['User'] = fields.ForeignKeyField('models.User', related_name='metas')
class User(BaseModel):
id = fields.IntField(pk=True)
name = fields.CharField(max_length=128, unique=True, description='名称')
email = fields.CharField(max_length=256, unique=True, description='邮件地址')
password_hash = fields.CharField(max_length=128, description='密码哈希')
metas: fields.ReverseRelation['Meta'] If __MetaInModel = pydantic_model_creator(Meta, exclude_readonly=True) There are 2 problems:
if I set __MetaInModel = pydantic_model_creator(Meta, name='__MetaInModel', exclude_readonly=True) |
Also receiving this error, lucky I stumbled upon this issue. |
Describe the bug
The
pydantic_model_creator
function gives different answers when called with thename
argument, compared to when it is omitted.To Reproduce
Expected behavior
That the same Pydantic classes (the second set) should be generated in both cases.
The text was updated successfully, but these errors were encountered: