kvesteri / wtforms-alchemy

Tools for creating wtforms from sqlalchemy models
Other
245 stars 59 forks source link

include_primary_key doesn't recognize the primary key. #156

Closed Amr-Hash closed 3 years ago

Amr-Hash commented 3 years ago

I have a model which has a user defined primary key so I assigned include_primary_keys to True

Model

class Model(db.Model):
    pk_col = db.Column(db.String(100), primary_key=True)
    some_other_col = db.Column(db.String(100))

Form

class CreateModelForm(ModelForm):
    class Meta:
        model = Model
        include_primary_keys = True

but when I send a request with pk_col to it it responded with

The calling ModelForm(data={'pk_col':'some_value'})

response

{
    "errors": {
        "pk_col": [
            "This field is required."
         ]
    }
}
Amr-Hash commented 3 years ago

Sorry it's my fault I was passing the request post to the form using Form(data=data) but it needed to be passed as From(data) with data being MultiDict