score:1
Accepted answer
tastypie doesnt automatically add relationship fields, you need to do them manually.
if you want to hit the rental endpoint and get related gallery resources, do the following:
class rentalresource(multipartresource,modelresource):
gallery = fields.tomany('path.to.galleryimageresource', 'gallery', related_name='rental', full=true)
class meta:
queryset = rental.objects.all()
resource_name = 'rental'
allowed_methods = ['get', 'post','put']
fields = ['listingname','ownername','room','price','summary']
filtering = { "property" : all , "room":all,"price":all}
authorization = djangoauthorization()
class galleryimageresource(modelresource):
rental = fields.foreignkey(rentalresource, 'rental', full=false, null=true, blank=true)
class meta:
queryset = galleryimage.objects.all()
resource_name = 'gallery'
allowed_methods = ['get','post','put']
authorization = djangoauthorization()
Source: stackoverflow.com
Related Query
- Fetch Foreign key object from an api using reactjs
- Fetch foreign key object instead of ID in React from Django API
- How do I fetch search results from multiple API using reactjs
- How to fetch data from Microsoft Custom Vision API using ReactJS
- How can I fetch data from an array of objects, pass it through an API end point to .fetch() the needed object value using React?
- Using ReactJs to fetch data from an API but getting completely blank page with no errors
- Make a for loop to show data object from API in render using Charts Reactjs
- Not able to fetch data from node.js API hosted on localhost using ReactJs
- React.js: loading JSON data with Fetch API and props from object array
- Post an object with fetch using react js and express API server
- How to pass data from one component to another while using API in reactjs
- displaying data from fetch api using react
- Fetch data using an id from an api but display an alternative text to address bar e.g. content_title in Next.js
- Express does not receive parameters via POST from React using Fetch API
- I can't fetch data from the api using useEffect
- ReactJS app is unable to fetch data using REST API call
- How can I create a button which Fetches image from API and download to the local with using ReactJs
- How to fetch data from API using id in reactJS?
- Error 415 when call POST API using Fetch in ReactJS
- ReactJS (beginner) Using Youtube API - Returned Object Not Allowing Me to Access VideoId Property
- How to fetch data in ReactJS from NodeJS API for Influxdb?
- Promise rejected in POST login using fetch API in reactjs and Nodejs
- How to make aspecific API call from within a Line Chart class in ReactJS using react-chartjs-2?
- ReactJS get token string from API fetch
- How to fetch data from json using Reactjs
- How to assign response from Api to an array using fetch function
- Best way to set state of object using dynamic key name? - reactjs
- ReactJs Cannot get value of an object from FETCH
- Display data from an API when clicking a button. Using ReactJS
- With React useState how do you access key values of an array returned from fetch API
More Query from same tag
- Understanding more about Hoc in Reactjs
- Updating lists on FrontEnd from MongoDB using mongoose and react
- Material-ui - TextField - Can't change helper text error color
- Change the state when clicking outside a component in React
- Referencing child component from styled component
- How to add a Material UI Tooltip on a Material UI Datagrid headername?
- NextJS react hook - Pass async state to child components
- Hide TabBar item in TabNavigator
- MouseEvent target type
- How to fetch and show data from rest api by searching in react.js
- How to change/update componentWillReceiveProps to getDerivedStateFromProps in React?
- Testing react component methods with HOC
- How to hide Nav bar in some react components
- Passing data from an input button click?
- Css loader invalid option with Nextjs
- How to loop in into multiple elements using single useRef?
- Fetch again, or set state? - react, redux
- In React app, iframe is showing up in developer tools, elements
- why my timer component is not working as a timer its time is not reducing
- Link of react-router-dom updates the URL without rendering the component
- react pass props from child to parent undefined
- How to execute JS in JSX (React) without outputting it as HTML?
- How to align Material-UI Menu items?
- nested react router sibling
- Pass prop to every single page in Next.js with getInitialProps using Typescript
- How to make api call with react-redux in functional components
- How retrieve current redux-form state field value in react class form component?
- How to implement SSR for Material UI's media queries in NextJs?
- Validate react-input-mask length using Formik + Yup
- react js hooks useEffect infinite loop