I’m trying to pass a response from JsonResponse as a parameter of specific function in views. But, got the following error instead Here it is my code url.py views.py file.html Answer Your success function is javascript that is running in the front-end. Django is not running your front-end and there is n…
Tag: django
Showing Image in django
I have a Django web app where I am uploading an image and showing some texts. But I am not able to show the image in the front end after uploading. views.py index.html How can I show the uploaded image here, I have little experience with javascript so If anyone can help me on this! what I tried so far
Django HTML & CSS render to pdf
I’m trying to convert HTML & CSS into a pdf page using Django-weasyprint but I’m kind of stuck with their tutorial because I want the PDF to render the current page when the user clicks on the download button and the pdf downloads automatically with read-only privileges. This whole process kin…
Django/Webpack – How to serve generated webpack bundles with webpack dev server
Django’s ‘static’ tag generates urls using STATIC_URL, which results in something like ‘/static/myapp/js/bundle.js’ Mean while, webpack-dev-server is serving bundles from the url ‘localhost:3000’ My question is how do I get Django ‘static’ template tag to …
Is there a way to restrict access to DRF interface while still being able to access api-endpoints?
I’m creating a site that has Django Rest Framework as its backend and ReactJS as its frontend. I have multiple api-endpoints for various data, i.e. I don’t want regular users to have direct access to the DRF interface. If anyone decides to go to one of those urls, I’d prefer to redirect them…
Multiple buttons with same function call, but alert only showing for the first button
I’ve been messing around with Vue.js and Django and I added a function call to a button. The button is shown multiple times for each different type of food there is, but the alert is only shown when the very first button is clicked. What could be the cause? Django template: JS: Answer Figured it out. I …
Getting seconds from a timer function to my view
I want to get the minutes and seconds from the timer in my template to my view. I already tried different approaches with an ajax.post request but it didnt really work how I wanted it to be. Here is my template: Now I want to get the minutes and seconds to my view as a POST request after clicking on
TypeError: data.forEach is not a function
This is my code: I get the error that for each does not work on the data variable. However, when I log data to the console, I get [{“model”: “app.mdl”, “pk”: 1, “fields”: {“name”: “test”, “rank”: 1}}] This is clearly an array …
Using Template Specific JavaScript in Django
I have a base_generic.html page in django that has the standard UI elements (navbar, footer, etc.), and I have a list.html page which extends the base_generic.html page. The list.html page is using a javascript function that is only used in this page, but for it to work, I have to include it in the base_gener…
Using JavaScript Onclick Event to pass Data to views.py in Django?
I Have a bit of idea about this to use ajax with the JavaScript to send data to views.py but I am not able to do that. So what I am trying to do is I have put onclick event on the image so by clicking on that image I should be able to send some value to views.py. This