Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Trying to complete the DJANGO intro tutorial as seen on the w3schools website - https://www.w3schools.com/django/django_intro.php
Following along the tutorial as seen on https://www.w3schools.com/django/django_intro.php Basically I have: Created virtual environment Started Django project - myworld Created a members app and edited the views exactly as mentioned Added to urls.py in the project and members directory Still get this error that empty path didn't match any of these A screenshot of the error message I am seeing instead of Hello world! and welcome to Django A screenshot of my urls.py file Is this an issue with me being in a wrong path, or do I need to specify more in path('blog', ) section? -
RSA encryption private key among a group of people
I am currently trying to implement the RSA encryption algorithm with my Django application. So the way I want it to be Is that the users enter some data through like quiz or surveys and then that data is encrypted using a public key of the users. Then I have a group of admins who only can see what the user enters in their own portal (not the Django admin), like maybe a group of admins at a school or something . How can I implement this ? Because a thing that struck me is that I can't decrypt the data with multiple private keys since 1 user's data can be shown to multiple admins for analysis purposes. So I want that a user's data should be decrypted and shown in the admin portal of multiple admins. -
How to overwrite form.valid with a funcion base view
So, i just want to tell my view, to use the request.user as the author of the company im creating. I can find how to do that with class base views, overwriting the form.valid, but i cant find how to do that with a funcion base view enter image description here -
Convert raw query to django ORM (prefetch_related, left join with mutiple conditions)
I want to convert the raw query to Django ORM, but I got no idea. SELECT * FROM user AS u LEFT JOIN animal AS a ON u.related_id = a.id AND u.type != 'animal' LEFT JOIN human AS h ON u.related_id = h.id AND u.type = 'animal'; tried something like User.objects.prefetch_related(Prefetch('name1', queryset=User.objects.exclude('animal'))).prefetch_related(Prefetch('name2', queryset=User.objects.finter('animal')) but it does not work like the raw query. Any help would be appreciated. -
How to fix CORS error while using Models.Pointfield function of GeoDjango Framework?
User is required to click on the location in map using Pointfield. This is my code for models class Marker(models.Model): """A marker with name and location.""" Market_Place_Name = models.CharField(max_length=255) GPS_Location = models.PointField() Http_Location = models.CharField(max_length=255) def __str__(self): """Return string representation.""" return self.name I get error message saying the following and map doesn't load either as shown below: I've tried adding these following codes on setting.py of geodjango project, but nothing seems to work INSTALLED_APPS = ['corsheaders'] MIDDLEWARE = ["corsheaders.middleware.CorsMiddleware",'django.middleware.security.SecurityMiddleware'] CORS_ALLOWED_ORIGINS = [ "http://localhost:8000", "http://127.0.0.1:8000"] -
How to get value from HTML select form inside the views?
1.In HTML template i created a select form passing into it player names from Player Model. 2.I want to delete the player selected in this form. 3.Inside my views, i am trying to get the selected value as a string but i can't. for me it would be Player.objects.get(name="what is selected inside the form"). Can you please help? What should i do in order to get this value inside my views? <div> <form method="POST" action = "" enctype="multipart/form-data"> {% csrf_token %} <select name="to_delete" > {% for pl in players %} <option value="1">{{pl.name}}</option> {% endfor %} </select> <input type="submit" value="Delete"/> </form> </div> def deletePlayer(request,pk,sk): room = Room.objects.get(number=pk) player = Player.objects.get(number=sk) players = Player.objects.filter(room=room) if request.method == "POST": result = reguest.get('1') to_delete = Player.objects.get(name=result) to_delete.delete() context = {'room': room, 'players':players,'player':player} return render(request, 'base/delete_player.html', context) -
@classmethod or @staticmethod In python(Django)
I have used spring framework for developing server application, and now I start to learn Django. I got one question when I use Django. "Is there no issue about memory when using @classmethod or @staticmethod? in python" In spring(java), there is issue about abusing static and spring also support controlling object(IoC container). But when I use Django, there is no decorator or setting about object. Just I use @classmethod, and use it with class name (ex. AccountService.join() ) -
Do I need to buy an SSL certificate for my new domain?
I was hosting my app on Heroku and it said it was "secure" in the domain bar with no problem. I have the following setting on: SECURE_SSL_REDIRECT = True Now I added my own domain and reconfigured my app to point to the domain. Did I lose some sort of SSL by doing this? Sometimes now I get an error when I try to load the webpage that says ERR_SSL_UNRECOGNIZED_NAME_ALERT -
Django funcion views, creating a company with user associated
So, i have this problem when im trying to create my "company", when i didnt have user authentication the view worked just fine. Now i've added django allauth, and this screen appears to me: enter image description here So i will leave here my model and my view to create the company Im just a begginner so sry for my bad explanation enter image description here enter image description here -
Is my payment processing secure (TLS) on Django/Heroku using Stripe
I'm using Stripe payment elements on my Django app hosted on Heroku. I have the following setting on: SECURE_SSL_REDIRECT = True What else do I need to do to make my website meet TLS? Do I need a TLS certificate from a site like Let’s Encrypt? -
Django Form Classes sometimes they don't appear?
This is the form below. Sometimes my form-control doesn't appear? I've used JQuery hasclass to check and add it if it fails. I just want to know why as my other forms are the same and work fine? Can't seem to figure out what the issue is. If anyone knows please let me know :) class holder_password_update_form(PasswordChangeForm): def __init__(self, user, *args, **kwargs): self.user = user super().__init__(user, *args, **kwargs) self.base_fields['old_password'].widget.attrs['class'] = 'form-control' self.base_fields['new_password1'].widget.attrs['class'] = 'form-control' self.base_fields['new_password1'].help_text = mark_safe('<p class="text-start" style="padding-left: 10px"> Your password can\'t be too similar to your other personal information, can\'t be a commonly used password, must contain at least 8 characters, 1 uppercase letter, 1 lowercase letter, 1 digit(s), 1 special character. </p>') self.base_fields['new_password2'].widget.attrs['class'] = 'form-control' self.base_fields['new_password2'].help_text = mark_safe('<p class="text-start" style="padding-left: 10px">Enter the same password as before, for verification.</p>') def save(self, commit=True): password = self.cleaned_data["new_password1"] self.user.set_password(password) if commit: self.user.save() return self.user -
Can you make a Django form dropdown box accept a model as its choices?
I have a real estate site where I am trying to be able to upload multiple photos to one 'property' without going through the django admin panel (so I can multi select photos.) Current view for custom built form I am able to choose multiple files, upload them to my 'uploads' folder and able to see them in the admin panel for databases. The issue is that the property name from the form I built doesn't connect the Property object to the Property Photos objects. Its just a null value. When I click on a Property Photo object only then does it assign the Property object to it. Property Photo objects BEFORE Property Photo object Once I click on it and push save Property Photo object After How do I get to be able to select (using a dropdown) a Property object from all my Property objects as a list and assign those photos uploaded to that Property object? Below are my: html form, models.py, views.py, and forms.py photo_upload.html <body> <form action="" method="POST" enctype="multipart/form-data"> {% csrf_token %} <div class="fs-1">Photo Upload</div> {{ image_form }} <button>Upload</button> </form> </body> models.py class Property(models.Model): class Meta: verbose_name_plural = 'Properties' address = models.CharField(max_length=150) slug = models.SlugField(unique=True, … -
Is it possible to have an input from a form in a html template be added to the url in a django project?
In the sidebar of my homepage, there is a search box where a user is meant to be able to type in the name of an entry and be taken to that page. So for example, if they type in css they would be taken to http://127.0.0.1:8000/wiki/css where the value inputted is appended to the url. (The home page url is http://127.0.0.1:8000/wiki/.) When I use the get method in the form it ends up searching up /wiki/?q=css instead of just having /css at the end of the url. However, when I use the post method in my form the url remains at http://127.0.0.1:8000/wiki/ with no additional url at the end. How do I append an input to the end of a url? HTML: <h2>Wiki</h2> <form action="/wiki/" method="post"> {% csrf_token %} <input class="search" type="text" name="q" placeholder="Search Encyclopedia"> </form> urls.py: from tokenize import Name from unicodedata import name from django.urls import path from django.http import HttpResponse from . import views urlpatterns = [ path("", views.index, name="index"), path('hello/', views.hello, name='hello'), path('<str:name>', views.entry, name='entry'), path('new/', views.new, name='new'), path('random/', views.randomEntry, name='random') ] views.py: from django.shortcuts import render from django.http import HttpResponse from django import forms import random from . import util def index(request): return render(request, … -
how to check if a date is expired or not django?
I have a model that contains informations about trips and one field is a DateTimeField() like this: class Voyage(models.Model): voyid = models.CharField(max_length=20, primary_key= True) depart = models.CharField(max_length=30) destination = models.CharField(max_length=30) datedep = models.DateTimeField() #the datedep is the time and date of the trip departure And the result is a list of trips so i want to output only the trips that are not expired: (datedep > now), how do i do that? -
django.urls.exceptions.NoReverseMatch: Reverse for 'xyz' not found. 'xyz' is not a valid view function or pattern name
i have problem bcz i get: Powershell: django.urls.exceptions.NoReverseMatch: Reverse for 'register' not found. 'register' is not a valid view function or pattern name. Project Schematic: https://ibb.co/g39qB9k Error during template rendering: https://ibb.co/k5k82V4 html: <a class="navbar-brand" href="{% url 'turbineweb:home_page' %}"> Turbine Power Web</a> <div class="collapse navbar-collapse" id="navbarResponsive"> <ul class="navbar-nav ms-auto"> {% if user.is_authenticated %} <li class="nav-item"><a class="nav-link" href="{% url 'accounts:logout' %}">Logout</a></li> <li class="nav-item"><a class="nav-link" href="{% url 'accounts:password_change' %}">Change Password</a></li> {% else %} <li class="nav-item"><a class="nav-link" href="{% url 'accounts:login' %}">Login</a></li> **<li class="nav-item"><a class="nav-link" href="{% url 'accounts:register' %}">Register</a></li>** {% endif %} <li class="nav-item"><a class="nav-link" href="">Turbine Models</a></li> <li class="nav-item"><a class="nav-link" href="">Author</a></li> {% if user.is_company %} <li class="nav-item"><a class="nav-link" href="">My Models</a></li> {% endif %} <li class="nav-item"> Hello, {{ user.username|default:'Guest' }} </li> </ul> </div> views: def home_page(request): return render(request, 'turbineweb/home_page.html') project urls: urlpatterns = [ path('admin/', admin.site.urls), path('', include('accounts.urls', namespace='accounts')), path('', include('turbineweb.urls', namespace='turbineweb')), ] accounts urls: app_name = 'accounts' urlpatterns = [ path('login/', CustomLoginView.as_view(redirect_authenticated_user=True, template_name='accounts/login.html', authentication_form=LoginForm), name='login'), path('logout/', auth_views.LogoutView.as_view(template_name='accounts/logout.html'), name='logout'), path('registration/', RegisterView.as_view(), name='users-registration'), path('password-change/', ChangePasswordView.as_view(), name='password_change'), path('password_reset/', auth_views.PasswordResetView.as_view(), name='password_reset'), path('password_reset/done/', auth_views.PasswordResetDoneView.as_view(), name='password_reset_done'), path('reset/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(), name='password_reset_confirm'), path('reset/done/', auth_views.PasswordResetCompleteView.as_view(), name='password_reset_complete'), ] turbineweb urls: app_name = 'turbineweb' urlpatterns = [ path('home/', views.home_page, name='home_page'), ] -
Django, return a value to the HTML file from a view when using a form
My index.html file contains three forms, each connect to my views.py file and perform some function, everything is working fine but I am not understanding how to get a returned value back to my html page to display it. index.html: <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Index</title> </head> <body> <form action="{% url 'start_or_end_fast' %}" method="POST"> {% csrf_token %} <button type="submit" name='start_fast' value='start_fast'>Add Fast</button> </form> <form action="{% url 'start_or_end_fast' %}" method="POST"> {% csrf_token %} <button type="submit" name='end_fast' value='end_fast'>End Fast</button> </form> <form action="{% url 'start_or_end_fast' %}" method="POST"> {% csrf_token %} <button type="submit" name='duration' value='duration'>Fast Duration</button> </form> <!-- DISPLAY FAST DURATION ON THE PAGE --> {% if duration %} <p>Fasting for {{duration}} </p> {% endif %} </body> </html> The third form is a button, when I press it the duration prints in the terminal. views.py code to do that: #If pressing Fast Duration button, show the duration difference between the current fast start_date_time and the current time elif request.method == 'POST' and 'duration' in request.POST: time_difference() return render(request,'startandstoptimes/index.html') else: return render(request,'startandstoptimes/index.html') def time_difference(): #Get the current date and time current_time = datetime.now().strftime(("%Y-%m-%d %H:%M:%S")) time_now = datetime.strptime(current_time, "%Y-%m-%d %H:%M:%S") #find the current fast that has not finished yet … -
Send Uint8List Image from Flutter to Django ImageField
Good day. I have an image of a signature, im using signature: ^5.0.1 for Flutter. I need to save it in to the ImageField. I haven't been able to save it in Django. this is my code inside flutter signaturePic(String imgName, SignatureController controller)async{ String completeUrl = '$rootApi/reports/signature_pic/'; var uri = Uri.parse(completeUrl); var request = http.MultipartRequest("POST", uri); Uint8List? signatureFile = await controller.toPngBytes(); if (signatureFile != null){ final multipartFile = http.MultipartFile.fromBytes(imgName, signatureFile); request.files.add(multipartFile); request.headers["authorization"]='TOKEN ${temp.apiKey}'; } } in Django 4.0 im using djangorestframework==3.13.1 class SignaturePicView(APIView): def post(self, request): try: for title, value in request.data.items(): items = title.split('__') is_return = True if items[5] == 'True' else False SignaturePic.objects.update_or_create( user=User.objects.get(id=request.user.id), unique_identifier=title, is_return=is_return, defaults={ 'image': value, } ) return Response(status=status.HTTP_201_CREATED) except ValueError as e: print(e) return Response(status=status.HTTP_400_BAD_REQUEST, data=e) this is the model in django class SignaturePic(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) date_created = models.DateTimeField(auto_now_add=True) date = models.DateField(auto_now_add=True) unique_identifier = models.CharField(max_length=220, null=True, blank=True) image = models.ImageField(upload_to='signatures/', null=True, blank=True) is_return = models.BooleanField(default=False) def __str__(self): return f"{self.unique_identifier} -> {self.date}" when it saves this is what I get. : �PNG IHDR�_>���sRGB���sBIT|d�IDATx��y|T�ـ���Lf&��KH�dGd�E(�@+�'"R-����+X~Z�¯h� |,� ���;(a��d�Lf2���1i��,!�I&�}��s����ߓ;�s�9�VKʃ�#Һ.@ �)��� ��؏���ٛ����p��� ��� �����>|e@�&s w��98s��:���=Hb��ۊ �������jDRI�W!KN�i���ױgeb;��H,�}����T�A�� ���h�T�~��:��0�X*���p�܊+�\����\? ��Uo�}&�J�*m } ނ3-}W�S�1���HRFh�4<�9���)Μ��!������������D�A,Eޤ���D�aH����`ٹ�ҵ�@��nЋ�; Gٶ/"��'�7.�l�;(Zt'~�"�q-~t� N�[t��Ll�� �( ��3ǽ�X���u�K��u�;��E?��[�'����[�0���cx�O����^��ts�k����!d�i$<�u�a�=W�Q��},�pZ�7����h{��Q��v-����!�m�8�--{��|A�z���9��{+�_��- 8-����8f>��Ի�8�-�9��kH��U�q�%����XD�U���וǥ�����&V)���)L���F��6$�̬�4 �S���8�e�BlY��R����2=��"�k^�X^�E��M%�s�lӇ�g�#5V�zA�z���e�Q�ͧ��b���~Xb�����V��M�[xe�I��"�=�ĉb��&,�a��A�1݀���@jhZ��E˧�vE�^$�����A���l��8���un?�>��{YrZ��,|��,��H���\U�8�8Q���̛��[xU�@��h٣ƱM�>�+�[ͻ7y1Rc�j�ĉ�gva��!��;P��~�ԝ�ql����G��E��c��'ͻ�(� N�<�����E�.F��~�k�L�y�`���W���YrI/f�l�@�C���M�uv7�C�t^�0fb��ǒ�L0��%O���~�o0<�F��V �S��X�}�u�'H�F\!�ID�1��!�I[��K���ف4���V��>6<�+ĩ�Ґ0�>�_n@����9F�6��'�`^;��q-H��YJzXs� NıY�u�2\yP��n��hz�ko�y,�R~��(Zt#y�ʈH�8�$�U�{��ၸ��J�<��[(Y� ���d+����}%�y~� Np�ڊy�;�/�8�-b��\� oR��=d��h�ۃțv�H�"�F�n;���q�+��țt"n�"����=���,��Ǚ���C?⵰��8aºo)e�߮l���A���A, {.g�vL+^@���,�5q�j�H��� A�b����V�|U��F�A�N�[������6��i+���T�������\=���)dI��G�A�k|�r���;,�7#��n�T��U/c?������ӣ$�\�|�_/Dz�C����1}��X�� �s\唬�����D���(���6��:�m}ۡ����hz?)�7�l�?"��A�*�<����xM��U�<4�� �H.������7��!oօ��/���TD�UA�*P��%��@�6����"v�qdo�xu��|�#��3���^Dr�A��`^?����5G��)O�>b�J��5�}��vS��E5�lIq�y�|ʶ�@����:"y�>�O��l�F�E�ح_��qn�y�|ʶ��0 �.G�kBD�x��0}��+ǐh�0��G��NqnA�Ǔ���DV��=�>}� … -
How can i print PDF with xhtml2pdf Django library on Heroku, when make deploy in Heroku doesn't work?
The library xhtml2pdf of Django doesn't work in Heroku, in local project works perfectly print PDF documents and credential after deploy Heroku not print PDF. The static files works because load the css and image just can't i print PDF references to be resolved using Django’s STATIC_URL and MEDIA_URL settings, xhtml2pdf allows users to specify a link_callback parameter to point to a function that converts relative URLs to absolute system paths. template/admin/credential.hmtl <!-- base.html --> {% load static %} <!doctype html> <html lang="es"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/material-design-iconic-font/2.2.0/css/material-design-iconic-font.min.css" integrity="sha256-3sPp8BkKUE7QyPSl6VfBByBroQbKxKG7tsusY2mhbVY=" crossorigin="anonymous" /> <title>Sentir Humano</title> <style> @page { size: A4; @frame content_frame { /* Content Frame */ left: 0pt; width: 587pt; top: 0pt; height: 700pt; } background-image: url('{% static "front/img/credential_front.png" %}'); } .test { font-size: 13px; } .person_id{ text-align: right; margin: 70px 50px 0px 205px; padding-top: 45px; } .first_name{ margin: 70px 0px 20px 45px; } .creator{ margin: 0 0px 0px 45px; } .date{ margin: 20px 0px 0px 45px; } .afiliado{ font-size: 14; margin-left: 45px; } </style> </head> <body> <table> <thead> <td class="test"> <p class="person_id">{{customer.person_id }}</p> <p class="first_name">{{ customer.first_name|upper }} {{ customer.last_name|upper }}</p> … -
My objects dublicate each other in django template
I'm trying to do my Django web-app and can't to overcome a problem. I need to split my model objects on two divs for correct display, but my dish objects just duplicate each other. I've tried to find info how to split my dishes objects on two parts and give them to html code, but it didn't works. Also there is can be a python templates solution, but I don't know how to resolve it, because the pure html code of project is something I never seen before (there is left-list and right-list classes for dishes columns, therefore we need to split our dishes dict somehow). There is 2 for loops because of the first row tag creates two col-lg-6 on left and right sides (this can be seen in the last image of page code of default template), maybe it's a bad idea. views.py: from django.shortcuts import render, redirect, HttpResponse from django.urls import reverse from .forms import ReserveForm from .models import ChefsModel, DishesModel # Create your views here. def reserve(request): chefs = ChefsModel.objects.all() dishes = DishesModel.objects.all() error = '' if request.method == 'POST': form = ReserveForm(request.POST) if form.is_valid(): form.save() return redirect('index') else: error = 'Invalid form' else: form = … -
Ajax post multiple inputs
I have html input fields with the name personals. I use the [] such that I can have multiple inputs on the same name and post that. Before I was using a normal submit form. And I got it in my Django backend with getlist('personal[]') Everything worked as expected. As information: the codes are not complete. Just the most important lines are shown. My html code before <input type="text" name="personals[]" id="personals[]" placeholder='Email'> <input type="text" name="personals[]" id="personals[]" placeholder='Phone'> My view before def build(request): if request.user.is_authenticated: if request.method == 'POST': name = request.POST.get('name') personals = request.POST.getlist('personals[]') Now I am using Ajax to submit it, without reloading the page. It does not work anymore with personals[] therefore I have changed it too personals just without the parenthesis. The problem is, that personal contains only the first input. But not all the others. It is important to use the same input name (in this case personals) because I use some dynamic input fields, where the users can add more fields. Therefore I don't want to change the name to for example personals1 and personals2. My html code now <input type="text" name="personals" id="personals" placeholder='Email'> <input type="text" name="personals" id="personals" placeholder='Phone'> My view now def build(request): if … -
hCaptcha Doesn't Render When Window is Too Small
I am using hCaptcha with Django. I am using the django-hcaptcha plugin. It renders and works properly except when the screen is too small. This is what is looks like normally: but when the screen is to small, this is what it looks like: I can't figure out any settings to configure this. How can I make sure the hCaptcha still renders even if the screen is smaller? -
do django urls need "/" at the end of it?
I'm using the newest form of django and I'm just wondoring whether or not urls need a "/" at the end: path('home', Home.as_view(), name='home'), vs. path('home/', Home.as_view(), name='home'), Is there any difference between the two? -
My objects in django-templates duplicate each other
I'm trying to do my Django web-app and can't to overcome a problem. I need to split my model objects on two divs for correct display, but my dish objects just dublicate each other. I've tried to find info how to split my dishes objects on two parts and give them to html code, but it didn't works. Also there is can be a python templates solution, but I don't know how to resolve it, because the pure html code of project is something I never seen before (there is left-list and right-list classes for dishes columns, therefore we need to split our dishes dict somehow). views.py: def reserve(request): chefs = ChefsModel.objects.all() dishes = DishesModel.objects.all() error = '' if request.method == 'POST': form = ReserveForm(request.POST) if form.is_valid(): form.save() return redirect('index') else: error = 'Invalid form' else: form = ReserveForm() return render(request, 'main/index.html', {'form':form, 'error':error, 'chefs':chefs, 'dishes':dishes, }) def index(request): return reserve(request) My Django template + HTML: <article id='tabs-1'> <div class="row"> {% for i in n %} <div class="col-lg-6"> <div class="row"> <div class="{% cycle 'left' 'right' %}-list"> {% for dish in dishes %} {% if dish.tabs == 'Breakfast' %} <div class="col-lg-12"> <div class="tab-item"> <img src="{{ dish.image.url }}" alt=""> <h4>{{ dish.name }}</h4> … -
What Python package to do mapping like Zillow? [closed]
We currently have lots of address data with longitude and latitude. I want to display data in the same way as Zillow does with a map on the left and property information on the right. I also need: additional property info is possible when clicking a point filters on the top property images on the right of filtered results Zillow is using Google Maps API, but we can use either that or Open Street Maps. What is the easiest way to do that on a Django server with a React front end? Packages or strategy is deeply welcome. -
How to add to Django Rest framework
Currently I have the following: backend/urls.py from django.contrib import admin from django.db import router from django.urls import path, re_path, include from pages import views from rest_framework import routers from reactUI import reactViews router = routers.DefaultRouter() router.register(r'reactCluster',reactViews.reactUIClusterView,'reactUI') urlpatterns = [ path('admin/', admin.site.urls), path('', views.homeView, name='home'), re_path(r'^getdata/',views.homeView), re_path(r'^loadAPI/',views.loadAPI), path('api/', include(router.urls)), ] backend/reactUI/reactViews.py from django import views from django.shortcuts import render from rest_framework import viewsets from .serializers import reactUIClusterSerializer from .models import reactUICluster # Create your views here. class reactUIClusterView(viewsets.ModelViewSet): serializer_class = reactUIClusterSerializer queryset = reactUICluster.objects.all() #helps with crud ops backend/reactUI/models.py from django.db import models from pandas import describe_option class reactUICluster(models.Model): title = models.CharField(max_length=200) physicalCPU = models.IntegerField() virtualCPU = models.IntegerField() #maybe add a list feild in cluster class def __str__(self) -> str: return self.title backend/reactUI/serializers/py from rest_framework import serializers from .models import reactUICluster class reactUIClusterSerializer(serializers.ModelSerializer): class Meta: model = reactUICluster fields = ('id', 'title', 'physicalCPU', 'virtualCPU') Front end in react import React, { Component, useState } from "react"; ~bunch of random other imports let counter = 0; function RefreshList() { const [row, setRow] = useState([]) const payload = { title :'a', physicalCPU:'b', virtualCPU:'c' } const axiosPost = () => { axios.post("http://localhost:8000/api/reactCluster/",payload).catch((err) => console.log(err)) } const axiomCall = () => { console.log("FF"); axios .get("http://localhost:8000/api/reactCluster/") …