score:3
Accepted answer
i'd recommend you do use django-rest-framework because it's probably easier with pagination.
however, if you want to avoid that you could pass your own structure (obviously, you may need to pass other information such as next page/previous page etc).
the challenge here is ensuring everything is json serializable - that means for queryset
you have to use .values() and wrap the result with list(). for paginator
you need to wrap with list().
from django.http.response import jsonresponse
def index(request):
influencers = influencer.objects.all().values()
paginator = paginator(influencers,16)
page = request.get.get('page')
paged_listings = paginator.get_page(page)
user_list = userlist.objects.all().filter(user_id = request.user.id).values()
queryset = list(chain(paged_listings,user_list),paginator.count)
content = {'total_page_count': paginator.num_pages, 'data': queryset}
return jsonresponse(content)
Source: stackoverflow.com
Related Query
- How to implement pagination in a Django and React app without using the REST framework?
- how to communicate between a root React component and the rest of the app using Redux?
- How to upload image to aws s3 using react and django rest framework
- How to add a legend to the map using react leaflet, without using refs and manually modifying the DOM?
- Django Rest Framework and React Front End: How to prevent unauthorized users from viewing private images if they get a hold of the image URL?
- How to make the filters work in this todo app created using react and redux?
- How to implement autocomplete user search in React and Django Rest Framework
- How to show the dialog everywhere in the app on clicking a button using react and typescript?
- How to add an image in the first react component and ignore in rest of the components using map function
- How to upload file to Django rest framework API using Axios and react hook form?
- How to programmatically add a className and a onLoad function to all the images in the project at once in React app without Jqyery
- How to implement like and unlike buttons in a react app using firebase
- How to show my reset password page in React using Django Rest Framework and Dj-rest-auth
- how to send data in GET request header using react and axios to Django rest framework?
- How to inject port and host using ENV variable in Create React App Proxy settings?
- How to do POST in FORM Submit using reactjs and pass the object value into REST service?
- CDN links for React packages and how to import it when using react using the scripts from CDN
- How to compress the files using gzip in react app
- How to create a preview (Image and description) to the Url when shared link on Social media,Gmail and Skype using React JS?
- How to Deploy Django Rest Framework and React on AWS
- How to use Django User Groups and Permissions on a React Frontend with Django Rest Framework
- "You require appropriate loaders", Using react native and expo. App fails to compile on the web, but runs on android
- How to import uikit js in react js without using the uikit component?
- How to make the API call and display it in React JS using React Table and Axios?
- How to build react app using Dockerfile.dev and Yarn
- How can I start my node server and react app at the same time?
- How can I cache data that I already requested and access it from the store using React and Redux Toolkit
- How to implement push notifications in React Native when the app is closed
- How to add page transitions to React without using the router?
- How to change the Swiper height or slide width in React JS without using fixed CSS
More Query from same tag
- Reach router not working on refresh on gh-pages
- Passing values to Stripe Checkout from shopping cart
- To Do List: Delete Button Removes Info from Wrong List Item
- Download file from FileStream return using React
- Making a Higher Order Component to inter-operate react-relay and react-router with TypeScript
- How to return the data which receive from Axios in Object form
- Why doesn't useEffect hook work as expected?
- Webpack ERROR - You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file
- Can I make Reason+React import react module from CDN?
- React dynamic select with button
- How to pass JS variables to JSX files
- React component re renders to it's initial state automatically
- React Native Transform Origin
- Tree Table - Setting children on react.js
- Live Heroku App has all broken images except background image (React/Node.js)
- Disable Button when clicked in React
- What's wrong with my delete button function - REACT
- Make sidebar (in React) take up 100% of the height of the page even when there's scrolling
- What is the best way to display all pictures of a directory in a Gatsby project using React?
- react - how do I get the size of a component child elements and reposition them
- react-router-dom > NavLink > multiple activeClassName?
- I can't get the fetched data to render on to the page
- How to update an array of objects with clickHandler and useState in Reactjs
- While I want to Display Error message, other component pops up error in React
- unable to read Data object
- Can't receive payload from emited event - Socket.io
- Cannot Get nor Set window.location using Enzyme and Jest
- How to redraw data in table when using onClick event in Material-table
- Fetch graphql query result on render and re-renders BUT LAZILY
- How to avoid input value reset in Reactjs?