Comments (2)
Hi,
I do not well understand what output you expect.
The models have to extend the Model class of flask_autocrud (I don't know what your BaseModel is). Your models should look like this (I have not tested):
from flask_autocrud import Model
db = SQLAlchemy()
class Company(db.Model, Model):
__tablename__ = 'company'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(150), nullable=False, unique=True)
class Address(db.Model, Model):
__tablename__ = 'addresses'
id = db.Column(db.Integer, primary_key=True)
address_id = db.Column(db.Integer)
company_id = db.Column(db.Integer, ForeignKey('company.id'))
company = relationship(Company, backref="addresses")
You can see an example, where entities are artists and albums, here
flask_autocrud/tests/test_custom.py
Line 168 in 2f53dc1
Actually is not possible, with GET method, to fetch multiple related resources and applying filters on it.
Let me know
from flask_autocrud.
Hi @maikotz there is new release available. Now even multiple related resource are retrived with GET.
The following is an example that should fit your need:
curl -XGET 'http://127.0.0.1:5000/artist?_related=Album&_fields=Name&_no_links='
{
"ArtistList": [
{
"AlbumList": [
{
"AlbumId": 4
},
{
"AlbumId": 348
},
{
"AlbumId": 349
}
],
"ArtistId": 1,
"Name": "AC/DC"
},
{
"AlbumList": [
{
"AlbumId": 3
}
],
"ArtistId": 2,
"Name": "Accept"
}
]
}
from flask_autocrud.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flask_autocrud.