drf-react | Combining Django Rest Framework and React , using webpack | REST library
kandi X-RAY | drf-react Summary
kandi X-RAY | drf-react Summary
To try it yourself, clone the repo and run:.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of drf-react
drf-react Key Features
drf-react Examples and Code Snippets
Community Discussions
Trending Discussions on drf-react
QUESTION
i am trying to make a CRUD app in DRF-Reactjs by following Tania rascia's example
i have successfully implemented add, delete, list view. but i am trying to edit a specific row which is not updating in DRF backend. but the edited row is shown in the frontend list. why it is not updating in django admin list?
in DRF side views.py:
...ANSWER
Answered 2021-Mar-12 at 23:51- Trying to update something should be done in a put request, not a post request. This is a REST API convention, but a discrepancy may have some consequence down the line.
- In this case, the error in your development tools is telling you that one of your components has an onChange/onSubmit etc property that is changing over the course of one mount from null to a function. This is not what's causing your issue, but I suspect it can be fixed by declaring the code in a handleSubmit function and then putting that into your onSubmit.
- I think the error that's actually causing your problem is that the updatedTodo is not being sent to the backend. All that is being sent is the id (second parameter of axios.post). So if you pause the backend during execution, you would see that request.data = the id only, when it should be TodoSerializer's readable fields.
PS:
- You can add a "debugger;" statement in the code after the updateToDo async request error to see what the error actually is (read more on the development tools debugging - browser dependent).
- Don't abuse fragments - in this case, it would make for a more accessibility-friendly experience if you use divs in most of these components. Wouldn't it make more sense if the heading of some content was grouped with the content? https://developers.google.com/web/fundamentals/accessibility/focus/dom-order-matters
QUESTION
My setup is running on Docker with a frontend (React) as well as a backend (Django) container.
I'm using the login-form component of the drf-react-app below in another project and am clueless as to how the api fetch request in the loginUser action creator (src/actions/user.js) knows which URL it is supposed to use..?
...ANSWER
Answered 2018-Mar-27 at 17:51In your package.json
you have a proxy
property set to "http://backend:8000"
. The proxy is used to redirect requests to a given url when you make a request against your local server http://localhost:3000
. So if that's not working then you might be missing a step that enables the proxy.
QUESTION
I am fiddling around with the following local drf-react setup. I'm really new to react and javascript overall and got absolutely no idea why I cannot import axios or any other node module for that matter in my react components, except for the modules that already shipped with the cookiecutter project itself. Is this related to the react-dev-utils..? I would like to use webpack, but I fail to set it up properly. My frontend docker container won't compose, telling me to install webpack-cli. Help is much appreciated.
...ANSWER
Answered 2018-Mar-21 at 12:58You should run the command npm install
inside your frontend folder:
- Open the terminal
- Find the frontend folder
- Inside of it run the command
npm install
This command will install the dependencies related to your package.json file, which is inside the frontend folder.
Inside your React files you will put the whole path to the node_modules folder.
The idea of using node_modules is to make it easier to control your dependencies in your project. You should consider again using webpack to handle these files from node_modules.
Wepack has a module called resolve
which you have to fill with a list of directories and inside React components you don't need to use the whole path anymore, because Webpack will understand where to look:
QUESTION
Working on a Django/DRF-React-Redux project. So I want to return specific messages for user login validation. If the credentials don't match, they get one error string, if the user is inactive they get another error string.
What I am trying to do is for one of the messages I need two line breaks and the other I want to render HTML because it should contain an email address. Anything I have read on SO, is not working. For example, regarding the HTML:
Put HTML into ValidationError in Django
Here is the method:
...ANSWER
Answered 2017-Sep-26 at 17:40Well, I ended up coming across: dangerouslySetInnerHTML
which took care of the issue.
https://facebook.github.io/react/docs/dom-elements.html#dangerouslysetinnerhtml
I changed the following for the DRF serializer.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install drf-react
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page