Skip to content

ValueError: cannot specify both default and default_factory #5

@harshitsinghai77

Description

@harshitsinghai77
class UserModel(models.Model):
    id = fields.UUIDField(pk=True)
    email = fields.CharField(null=False, max_length=255)
    hashed_password = fields.CharField(null=True, max_length=255)
    is_active = fields.BooleanField(default=False)
    confirmation = fields.UUIDField(null=True)

When running this I'm getting an eror:

ValueError: cannot specify both default and default_factory

The issue is probably caused by
id = fields.UUIDField(pk=True)

and

User_Pydantic = pydantic_model_creator( UserModel, name="User", exclude=("hashed_password", "confirmation") )

changing it to
id = fields.IntField(pk=True)

resolves the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions