Skip to content
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

flask_restless.manager.IllegalArgumentError: Provided model must have an id attribute #676

Open
pekof opened this issue Jan 16, 2018 · 4 comments

Comments

@pekof
Copy link

pekof commented Jan 16, 2018

I'm working with legacy database table where primary key is not named id but JobID or ID, so when I try

manager.create_api(PhClientOut, primary_key='JobID', methods=['GET'])

I get error
File "D:/0work/Transfer/central/central.py", line 125, in <module> manager.create_api(ClientOut, methods=['GET'], primary_key='JobID') File "C:\Users\frane\AppData\Local\Continuum\Anaconda3\lib\site-packages\flask_restless\manager.py", line 830, in create_api blueprint = self.create_api_blueprint(blueprint_name, *args, **kw) File "C:\Users\frane\AppData\Local\Continuum\Anaconda3\lib\site-packages\flask_restless\manager.py", line 604, in create_api_blueprint raise IllegalArgumentError(msg) flask_restless.manager.IllegalArgumentError: Provided model must have anid attribute

There should be way to define alternative id attribute name.

@rudaporto
Copy link

Which version are you using?

Can you try the current master branch?

@pekof
Copy link
Author

pekof commented Feb 6, 2018

flask-restless==1.0.0b1

flask==0.12.2
flask-babel==0.11.2
Flask-Bootstrap==3.3.7.1
flask-sqlalchemy==2.3.2

I will see if I could run master

@pekof
Copy link
Author

pekof commented Feb 6, 2018

It's working with current master branch

@jayarajanjn
Copy link

jayarajanjn commented May 17, 2020

You can define a new id field just in the model and map it the relevant primary key column.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants