You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there, I hope one of you can help me with the strange following question.
First of all, I've create a Model with SQLAlchemy:
(Note that the BaseModel is my BaseModel with a UUID included.
class Company(BaseModel):
reseller = Column(UUIDType(), ForeignKey('company.uuid'))
name = Column(VARCHAR(500), unique=True, nullable=False)
The next step is to create the actual Form.
class CompanyForm(ModelForm):
class Meta:
model = Company
After that, I wanna debug what kind of validators there are active on the name column:
c = CompanyForm()
print(c.name.validators)
# [<wtforms.validators.InputRequired object at 0x1068455e0>, <wtforms.validators.DataRequired object at 0x106845640>, <wtforms.validators.Length object at 0x1067bc130>, <wtforms_alchemy.validators.Unique object at 0x1067bc550>]
The next step is to call the form in the Rest API incoming response with the data given to the object. But InputRequired / DataRequired always validate to False.
# When using -D (curl) the DataRequired() is successfully, but the InputRequired failed
➜ ~ curl -XPUT -d '{"name": "bart"}' -H 'Content-Type: application/json' http://localhost:5000/api/v1/company/
# When using -F the InputRequired is sucessfully, but the dataRequired failed.
➜ ~ curl -XPUT -F "name=bart" http://localhost:5000/api/v1/company/
Removing the nullable=False will fixed this problem. Is there someone who can help me? :-)
The text was updated successfully, but these errors were encountered:
Hi there, I hope one of you can help me with the strange following question.
First of all, I've create a Model with SQLAlchemy:
(Note that the BaseModel is my BaseModel with a UUID included.
The next step is to create the actual Form.
After that, I wanna debug what kind of validators there are active on the name column:
The next step is to call the form in the Rest API incoming response with the data given to the object. But InputRequired / DataRequired always validate to False.
Removing the
nullable=False
will fixed this problem. Is there someone who can help me? :-)The text was updated successfully, but these errors were encountered: