ajax

How to Change the Format of a DateTimeField Object when it is Displayed in HTML through Ajax?

How to Change the Format of a DateTimeField Object when it is Displayed in HTML through Ajax? Question: models.py class Log(models.Model): source = models.CharField(max_length=1000, default=”) date = models.DateTimeField(default=datetime.now, blank = True) views.py The objects in the Log model are filtered so that only those with source names that match a specific account name are considered. …

Total answers: 2

Returning two arrays from a python script in Django and utilizing in Ajax simultaneously

Returning two arrays from a python script in Django and utilizing in Ajax simultaneously Question: I have a python script running in views.py within Django which returns two very large string arrays, x and y. It currently is able to run off a button press within my index.html. def python_file(request): final() return HttpResponse("ran") The ajax …

Total answers: 2

Ajax Flask Retrieve Data of Multiple Forms in Server Side

Ajax Flask Retrieve Data of Multiple Forms in Server Side Question: I am sending multiple form data as an formdata object using ajax to python flask. Just like the example here. In the below code, I am sending data of two forms using ajax to flask. I can’t retrieve it on server side, However I …

Total answers: 1

Retun data from a Django view after a javascript AJAX POST request

Retun data from a Django view after a javascript AJAX POST request Question: I am using Javascript to send an asynchronous request to a Django View. The View is able to receive data from the POST request, but I can’t seem to return a message to confirm that everything worked. I was expecting that xhttp.responseText …

Total answers: 1

Django4: Ajax AttributeError

Django4: Ajax AttributeError Question: I’m trying to create this Ajax request: The views file is as follows: reports/views.py from django.shortcuts import render from profiles.models import Profile from django.http import JsonResponse from .utils import get_report_image from .models import Report from .forms import ReportForm # Create your views here. def create_report_view(request): form = ReportForm(request.POST or None) if …

Total answers: 2

Sending data asynchronously from Flask to Front-end

Sending data asynchronously from Flask to Front-end Question: I have a DNA scanning tool. I want to send and receive data asynchronously. After every action in Flask, I want to send data to the front-end which will tell the user what is happening. Here is my code: FLASK: @app.route(‘/upload’, methods = [‘GET’,’POST’]) def upload(): if …

Total answers: 1

Create a new jpg file when user hits the route- Flask-Ajax

Create a new jpg file when user hits the route- Flask-Ajax Question: app = Flask(__name__) @app.route(‘/’ , methods = [‘GET’, ‘POST’]) def index(): print("hello") if request.method == ‘GET’: text = request.args.get("image") print(text) base64_img_bytes = text.encode(‘utf-8’) with open(‘decoded_image.jpeg’, ‘wb’) as file_to_save: decoded_image_data = base64.decodebytes(base64_img_bytes) file_to_save.write(decoded_image_data) The above code is my app.py in which an ajax request …

Total answers: 1

Django ajax search button more than one data

Django ajax search button more than one data Question: I have a django project. In this project, I made a search box with ajax, but the same data is coming more than once. Is the problem in ajax? or is the problem in django? I am not sure. Please help me. Hey guys.I have a …

Total answers: 1

Display an item search in ajax format from an ecommerce website

Display an item search in ajax format from an ecommerce website Question: I am trying to scrape an ecommerce website (Lazada.sg) and I found a Github code based of on scrapy: https://github.com/talk2div/lazada-scraper. As I’m tinkering how he developed his code, however, I cannot replicate displaying the same URL search in ajax format (correct me if …

Total answers: 1

Ajax form not sending data in django

Ajax form not sending data in django Question: I am trying to send data to Django without page refresh. So I am using ajax. Created a Django model and form class MyModel(models.Model): text=models.CharField(max_length=100) class MyForm(forms.ModelForm): class Meta: model=MyModel fields = "__all__" Then send the form to the HTML page via views.py def home(request): print(request.POST.get(‘text’,False)) form …

Total answers: 1