Questions tagged [django-react]

50 questions
1
vote
1 answer

Why won't the urls.py file in my Django project let me import this file?

I'm trying to import a list from a file in another directory into my urls.py file. I have included the directory in the settings.py file, ran the ./manage.py makemigrations & the ./manage.py migrate Django commands, and imported the function and the…
logan
  • 15
  • 5
1
vote
3 answers

ReactJS Imports not working blank webpage

I am a beginner learning ReactJS and was trying to make a full-stack quiz web application using DjangoRestFramework+ReactJS. The Problem I am not seeing anything rendering to my webpage when I try using imports. I am not getting any errors, but my…
1
vote
2 answers

Forbidden (403) Post Request in a "Build React App" but work fine with React App running on "http://localhost:3000/" and PostMan

I am using Django Rest Framework and React. When I run the react app on "localhost:3000", every post request is accepted and worked fine. But After I build the react app with "npm run build". Then, all POST requests are being Forbidden(403) on…
1
vote
1 answer

GET API showing KeyError in browser, but working in Postman

I have encountered a strange problem where the GET API that I created was working fine in Postman, but not working at that specific URL when entered in the browser. Here is what the input and output should look like as shown successfully in Postman:…
1
vote
1 answer

How to print a Django List on react js frontend

I have a list as follows: ["test1","test2","test3","test4"] I have the following serializer class: class ListSerializer(serializers.Serializer): key=serializers.ListField() This is views.py file: class ListView(APIView): def get(self,…
1
vote
1 answer

404 Error: unable to serve static react build with django rest framework, unless I go to /index.html

I have a React front end that I turned into static files. I used npm run build to make the folder. Then I configured my Django Rest Framework: settings.py FRONTEND_ROOT = os.path.abspath(os.path.join(BASE_DIR, '..', 'frontend',…
VickTree
  • 889
  • 11
  • 26
1
vote
3 answers

Django+React integration

I have Django Rest Framework server running in a terminal and React running in another terminal. I consume Django API's in React using axios as mentioned below axios.get('http://localhost:8000/songs/').then(res=>console.log(res) It work…
Anoop K George
  • 1,605
  • 12
  • 40
0
votes
0 answers

Django template does not find the correct directory path even when specified in settings.py

I have a Django project that includes two React apps, and I am using Django to serve them. I have set up my settings.py file to include the directories for both React apps in the TEMPLATES and STATICFILES_DIRS sections as follows: TEMPLATES = [ …
0
votes
0 answers

Django/react authenticated user not being returned

I am trying to show user profile page when user is logged in.I tested it with postman and printed in terminal and it is working.I can login and a user object is returned and when I go to the user profile route it returns the posts of the logged in…
0
votes
1 answer

"options.allowedHosts[0] should be a non-empty string." when using PROXY with REACT and Django as backend in LOCALHOST

im facing error while im trying to use proxy in package.json on react app and connect to django backend api in local host but when i tried to npm start i get this error: Invalid options object. Dev Server has been initialized using an options object…
0
votes
1 answer

React/Django App: Need to update a field in a put route, with a custom function in the backend, before saving with a serializer

I'm trying to change the content of a field with my own function. I'm using a simplified function that adds commas between each word. I want to be able to send my comma-fied sentence to the frontend but I don't know how to do that with the…
0
votes
0 answers

How to display an image from blob storage on my react/django website

My website is built with react/django. My website allows users to view vases from a database, each vase has 0,1 or many images(aka plate). The images are stored in Azure blob storage account and they are saved as their ID (plateRef). My database has…
0
votes
1 answer

How to upload image/media file from React to Django API?

I am able to save the data without the image field. I am new to react so don't know pretty much about this type of problems. What is the problem with the image field?? this isn't showing me any error just my image data is not saving. I am sharing…
0
votes
1 answer

python manage.py runserver shows an old webapp page I developed

I am learning Django so I've created many Django webapps under one directory. For example, \webapps \polls \polls \api \manage.py ... \ponynote \ponynote \frontend \manage.py ... I didn't use a virtualenv for…
KailiC
  • 111
  • 1
  • 10
0
votes
1 answer

Integrating react with django

I am learning how to integrate react with Django.. I found the tutorial by Dennis Ivy useful.. (linked below). So according to that video, where we create a Django project, and create a separate folder with npx create-react-app appname, we need to…
user14653534