Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to subscribe to GCP Pub/Sub when running a server of Django?
I have a backend service using django, I need to subscribe a message queue hosted on GCP pub/sub Here's the example code provided by Google: https://cloud.google.com/pubsub/docs/pull Implementing a function is easy, but I will have to start the django server via the command like: python manage.py runserver Or ASGI commands This subscribing function should be running continuously, better in the background, How can I achieve this? -
How to create a filter a column in a data table in Django?
I have a data table in my Django project. This data table is for listing customers. The customer has attributes like name, country, email, etc... I want to put a button like a dropdown menu for listing countries of customers. (Excel-like or similar logic) But I just need this in the country column. How can I do that? customer_list.html {% extends "layouts/base.html" %} {% block title %} Customer List {% endblock %} <!-- Specific Page CSS goes HERE --> {% block stylesheets %}{% endblock stylesheets %} {% block content %} <div class="content"> <div class="page-inner"> <div class="page-header"> <div class="row"> <div class="col"> <h4 class="page-title">Customer List</h4> </div> <div class="col"> <a href="/customer"> <button class="btn btn-primary btn-round" style="">Add new customer</button> </a> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="card"> <div class="card-header"> <h4 class="card-title">My Customers</h4> </div> <div class="card-body"> <div class="table-responsive"> <table id="multi-filter-select" class="display table table-striped table-hover grid_" > <thead> <tr> <!-- class="filter" --> <th index="0">Customer Name</th> <th>Country</th> <th>E-Mail</th> <th>Phone</th> <th>VAT Number</th> <th>Operations</th> </tr> </thead> <tfoot> <tr> <th>Customer Name</th> <th>Country</th> <th>E-Mail</th> <th>Phone</th> <th>VAT Number</th> <th>Quick Operations</th> </tr> </tfoot> <tbody> {% for customer in customer_list %} <tr> <td>{{customer.customer_name}}</td> <td>{{customer.country}}</td> <td>{{customer.email}}</td> <td>{{customer.telephone}}</td> <td>{{customer.VATnumber}}</td> <td> <div class="row"> <a href="/customers/{{ customer.id }}/profile" class="btn btn-outline-primary btn-sm" data-toggle="tooltip" title="View Customer" ><i class="fas … -
send django model form to view as response
any way to send django model form as JsonResponse?! It's a simple edit form where I am passing id to view using axios post request, and inside the view i catch the instance form of that id, (the problem appears here how to send back this instance form to my template). I've tried django-remote-forms there i get errors as the object type is not is not JSON serializable.. and so on errors. any better way where I'm doing wrong please inform me(new to django:) -
Django Allowed_host issue despite entered in field
I was following this tutorial about Django 08:00 integration and I can't access any hosts other than local domains. I have configured the allowed hosts as such: ALLOWED_HOSTS = ['test.domains','productivity','127.0.0.1','localhost'] I run the Django server using this command: python manage.py runserver 0.0.0.0:8002 What I am trying to do is to access the Django website using by typing this URL (for example) http://test.domains:8002. For the life of me, I can't seem to get it working as simply as Tony does. I've been on countless thread about allowed_hosts but all of them seems to be solved once you entered the socked in the allowed_host list, and I've also restarted apache 2. Of note, when I use, for example 0.0.0.0:8002 I see the notification in the terminal about 0.0.0.0 not being part of the allowed domains but when I try any test.domains or productivity there is no ping. Thank you for your time and help. -
Application Error after successfully deploying Django API to Heroku
I am making an api for my deep learning model. The api is properly working on localhost. I tried to deploy it on Heroku. It is deployed but when I open the link it gives "Application error" like below image Application error image Release log: 2021-02-23 05:47:36.841582: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set Operations to perform: Apply all migrations: admin, auth, contenttypes, sessions Running migrations: Applying contenttypes.0001_initial... OK Applying auth.0001_initial... OK Applying admin.0001_initial... OK Applying admin.0002_logentry_remove_auto_add... OK Applying admin.0003_logentry_add_action_flag_choices... OK Applying contenttypes.0002_remove_content_type_name... OK Applying auth.0002_alter_permission_name_max_length... OK Applying auth.0003_alter_user_email_max_length... OK Applying auth.0004_alter_user_username_opts... OK Applying auth.0005_alter_user_last_login_null... OK Applying auth.0006_require_contenttypes_0002... OK Applying auth.0007_alter_validators_add_error_messages... OK Applying auth.0008_alter_user_username_max_length... OK Applying auth.0009_alter_user_last_name_max_length... OK Applying auth.0010_alter_group_name_max_length... OK Applying auth.0011_update_proxy_permissions... OK Applying auth.0012_alter_user_first_name_max_length... OK Applying sessions.0001_initial... OK Build log: -----> Building on the Heroku-20 stack -----> Python app detected ! Python has released a security update! Please consider upgrading to python-3.7.10 Learn More: https://devcenter.heroku.com/articles/python-runtimes -----> Requirements file has been changed, clearing cached dependencies -----> Installing python-3.7.8 -----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2 -----> Installing SQLite3 -----> Installing requirements with pip Collecting absl-py==0.11.0 Downloading absl_py-0.11.0-py3-none-any.whl (127 kB) Collecting asgiref==3.3.1 Downloading asgiref-3.3.1-py3-none-any.whl (19 kB) Collecting astunparse==1.6.3 Downloading astunparse-1.6.3-py2.py3-none-any.whl (12 kB) Collecting cachetools==4.2.1 Downloading cachetools-4.2.1-py3-none-any.whl … -
I need to styling the FileInput by adding bootstrap class and it do nothing
I need to styling the FileInput by adding bootstrap class, and after I added the bootstrap class for forms it did nothing, How Can I styling the both (FileInput) and (ClearableFileInput) by bootstrap or by styling manully My form class Video_form(forms.ModelForm,): class Meta: model = Video fields = ('video', 'video_poster') widgets = { 'video_poster': forms.ClearableFileInput(attrs={'class': 'form-control'}), 'video': forms.FileInput(attrs={'class': 'form-control'}), } My views def VideosUploadView(request, *args, **kwargs): all_videos = Video.objects.all() V_form = Video_form() video_added = False if not request.user.is_active: # any error you want return redirect('login') try: account = Account.objects.get(username=request.user.username) except: # any error you want return HttpResponse('User does not exits.') if 'submit_v_form' in request.POST: print(request.POST) V_form = Video_form(request.POST, request.FILES) if V_form.is_valid(): instance = V_form.save(commit=False) instance.author = account instance.save() V_form = Video_form() video_added = True contex = { 'all_videos': all_videos, 'account': account, 'V_form': V_form, 'video_added': video_added, } return render(request, "video/upload_videos.html", contex) The html template <form action="." method="post" enctype="multipart/form-data"> {% csrf_token %} {{V_form.as_p}} <input type="file" name="" value="" accept="video/*" class="form-control"> <button class="btn btn-primary btn-block mt-5" name="submit_v_form"> <i class="icon-upload icon-white " name="submit_v_form"></i> Upload </button> -
django Models One Author to Multiples Books Relationship
I'm trying to create a relationship on Django on models.py one Author could be the writer of multiples books for a Bookshop project. Please find below how the models.py looks. I'm afraid is not working correctly. Thank you. from django.db import models from django.utils import timezone from django.urls import reverse # Create your models here. class Category(models.Model): # books categories name = models.CharField(max_length=200,db_index=True) slug = models.SlugField(max_length=200,unique=True) class Meta: ordering = ('name',) verbose_name = 'category' verbose_name_plural = 'categories' def __str__(self): return self.name def get_absolute_url(self): return reverse('category_detail',args=[self.slug]) class Product(models.Model): # books as products category = models.ForeignKey(Category,related_name='products',on_delete=models.CASCADE) book_id = models.CharField(max_length=10, db_index=True, blank=True) name = models.CharField(max_length=200, db_index=True) slug = models.SlugField(max_length=200, db_index=True) image = models.ImageField(upload_to='products/%Y/%m/%d',blank=True) image2 = models.ImageField(upload_to='products/%Y/%m/%d',blank=True) image3 = models.ImageField(upload_to='products/%Y/%m/%d',blank=True) description = models.TextField(blank=True) price = models.DecimalField(max_digits=10, decimal_places=2) available = models.BooleanField(default=True) created = models.DateTimeField(default=timezone.now) updated = models.DateTimeField(auto_now=True) class Meta: ordering = ('-created',) index_together = (('id', 'slug'),) def __str__(self): return self.name def get_absolute_url(self): return reverse('product_detail',args=[str(self.slug)]) class Author(models.Model): # book's author product = models.ForeignKey(Product,related_name='authors',on_delete=models.CASCADE) first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) def __unicode__(self): return self.first_name + " " + self.last_name -
Axios not responsive at all, React Native with Django backend
I am trying to make a post request to a django-based REST API inside an RN project with an Axios post request. I am getting no network error messages, no crash, no errors no whatsoever. I tried the same code on an Expo project and I was facing the same reaction (no reaction). I already did all required steps (like using the IP address instead of localhost) for making Django local-host development-friendly: CORS_ORIGIN_ALLOW_ALL = True CORS_ALLOW_CREDENTIALS = True ALLOWED_HOSTS = ['*'] Also 'rest_framework', 'corsheaders', as well as 'django.middleware.common.CommonMiddleware', 'corsheaders.middleware.CorsMiddleware', I installed the latest packages for Axios, RN. The server is not receiving any requests at all too. So my initial guess is there is something blocking like an SSL issue or some kind of internal-error/loop. Disabled the firewall too, and you can guess the scenario. -
Django ImportError: Module "social_core.backends.google" does not define a "GoogleOpenId" attribute/class
I've cloned my working Django app into a Debian based Linux distribution, I've installed all dependencies, but when trying to login with email and password or with Google account it throws me the following error: ImportError: Module "social_core.backends.google" does not define a "GoogleOpenId" attribute/class I have the following dependencies for authentication: django-allauth==0.42.0 django-rest-auth==0.9.5 google-auth==1.27.0 oauthlib==3.1.0 requests-oauthlib==1.3.0 social-auth-app-django==3.1.0 social-auth-core==4.0.3 It was working well in Ubuntu and MacOs, the problem have appeared cloning to this Debian Based Distro. -
Apache server is not starting
I have one python Django project on our intranet server folder like "//xxx.com/.../myproject/", and I set up virtual env under it as python interpreter "//xxx.com/.../myproject/py37-venv". I installed WampServer on my desktop computer (windows 10) and also on one windows server 2016, and testing apache server for Django server deployment. I followed this article to test apache: https://www.codementor.io/@aswinmurugesh/deploying-a-django-application-in-windows-with-apache-and-mod_wsgi-uhl2xq09e Added the following into httpd.conf: LoadFile "C:/Python/Python37_64//python37.dll" LoadModule wsgi_module "//xxx.com/.../myproject/py37-venv/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd" WSGIPythonHome "//xxx.com/.../myproject/py37-venv" Replace all 80 port in httpd.conf to 8888. I tested with httpd.exe -t, reported "Syntax ok" I tested with httpd.exe -e debug, it stopped and exited after this as below. I guess it is supposed to be continuously running after "generating secret...", right? It seems crashed although the modules loaded successfully: ....... [Mon Feb 22 20:33:21.815182 2021] [so:debug] [pid 18624:tid 776] mod_so.c(266): AH01575: loaded module vhost_alias_module from C:/wamp64_323/bin/apache/apache2.4.46/modules/mod_vhost_alias.so [Mon Feb 22 20:33:21.817180 2021] [so:debug] [pid 18624:tid 776] mod_so.c(266): AH01575: loaded module php7_module from C:/wamp64_323/bin/php/php7.3.21/php7apache2_4.dll [Mon Feb 22 20:33:21.829179 2021] [so:debug] [pid 18624:tid 776] mod_so.c(336): AH01576: loaded file C:/Python/Python37_64/python37.dll [Mon Feb 22 20:33:21.878180 2021] [so:debug] [pid 18624:tid 776] mod_so.c(266): AH01575: loaded module wsgi_module from //xxx.com/.../py37-venv/Lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd [Mon Feb 22 20:33:21.879186 2021] [auth_digest:debug] [pid 18624:tid 776] mod_auth_digest.c(371): AH01757: generating secret for digest authentication I … -
I am creating a backend for eber website but in got his error
i am creating backend for eber website but got an error this is the code 'from django.db import models from django.contrib.auth.models import ( BaseUserManager, AbstractBaseUser ) # Create your models here. class CustomUserManager(BaseUserManager): def create_user(self, email, password = None, **kwargs): if not email: raise ValueError('Users must have an email address') user = self.model( email = self.normalize_email(email), ) user.set_password(password) user.save(using = self._db) return user def create_superuser(self, email, password= None): user = self.create_user( email, password = password, ) user.is_admin = True user.is_staff = True user.save(using=self._db) return user class User(AbstractBaseUser): email = models.EmailField( verbose_name = 'email address', max_length = 255, unique = True, ) is_admin = models.BooleanField(default = False) is_active = models.BooleanField(default=True) USERNAME_FIELD = 'email' objects = CustomUserManager() #USERNAME_FIELD = 'email' def __str__(self): return self.email def has_perm(self, perm, obj= None): "Does the user have a specific permission?" return True def has_module_perms(self, app_label): "Does the user have permissions to view the app?" return True' the error i got is this 'TypeError at /api/v1/users/ create_user() missing 1 required positional argument: 'username' Request Method: POST Request URL: http://127.0.0.1:8000/api/v1/users/ Django Version: 3.1.5 Exception Type: TypeError Exception Value: create_user() missing 1 required positional argument: 'username' Exception Location: /home/danish-khan/django_drf/eberbackend/apps/users/views.py, line 14, in create Python Executable: /home/danish-khan/django_drf/django/bin/python Python Version: 3.8.5 … -
Convert to python TimeField object
I have been googling around but surprisingly haven't seen what I was looking for. I have strings like these '11:00 am', '12:00 pm', How does one convert this to Django models.TimeField() object. -
Django get request.POST.get() parameter not working as expected, parameter name with brackets[]
I have a code that is behaving really strange. The view receives a POST request with a key "tags[]", it is a list. I need to get that list but request.POST.get() only returns the last item of the list. This is the code: .... elif request.method == "POST": print("REQUEST POST:") print(request.POST) print("---------------------------") tags = request.POST.get("tags[]") print("tags: %s" % tags) print("---------------------------") And it prints the following: REQUEST POST: <QueryDict: {'csrfmiddlewaretoken': ['PAgg9VKGosBQUn8tBBb09NdeVgE8tcAaQz2EMbkQZPiJi289hBf7MHIKM1jF8mvp'], 'event_type_description': ['live_course'], 'title': [''], 'description': [''], 'platform_name': ['Zoom'], 'other_platform': [''], 'record_date': [''], 'date_start': [''], 'date_end': [''], 'time_day': ['12:00 PM'], 'schedule_description': [''], 'tags[]': ['not', 'normal', 'very', 'strange'], 'event_picture': ['']}> --------------------------- tags: strange --------------------------- As you can see, the value of the tags variable is "strange", the last item in the list. Why not all the list? request.POST.get is behaving in an unexpected way. Am I missing something? -
Username state gets undefined / null after a few minutes in JWT authentication React Django
I am making a React application with the backend of the Django REST framework. Everything works fine except when retrieving the username. Retrieving the username is no problem but keeping it for a time is a problem. I'm going to explain using comments now in the code; import React, { Component } from 'react'; import Nav from './Components/Navbar'; import LoginForm from './Components/LoginForm'; import SignupForm from './Components/SignupForm'; import Layout from './Containers/Layout'; import './App.css'; class App extends Component { constructor(props) { super(props); this.state = { displayed_form: '', logged_in: localStorage.getItem('token') ? true : false, username: '', // username state error: null }; } componentDidMount() { if (this.state.logged_in) { fetch('http://localhost:8000/core/current_user/', { // fetch is used to get current user headers: { Authorization: `JWT ${localStorage.getItem('token')}` } }) .then(res => res.json()) .then(json => { this.setState({ username: json.username }); // set the state }); } } handle_login = (e, data) => { e.preventDefault(); fetch('http://localhost:8000/token-auth/', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(res => res.json()) .then(json => { try { localStorage.setItem('token', json.token); this.setState({ logged_in: true, displayed_form: '', username: json.user.username, error: '', }) } catch (error) { this.setState({error: "We Couldn't log you in, maybe theres a typo in the data you entered"}) this.handle_logout() } }); … -
Can you use MapBox to have web users add locations?
I am very new to webdesign. I want to create a website where users can add locations/ change information about a location using MapBox. Is this possible? Can someone help me understand this process. If I can't use mapbox, could someone give me an alternate platform? -
Python virtualenv installed package not found
I cannot import djangoin my fresh virtualenv installation (python 3.7.9). So far : $ virtualenv env $ source env\bin\activate $ (env) pip install django $ (env) pip freeze asgiref==3.3.1 Django==3.1.7 pytz==2021.1 sqlparse==0.4.1 All good so far. Except: $ (env) python >>> import django ModuleNotFoundError: No module named 'django' I've tried : where django-admin my_website/env/bin/django-admin So clealy if my command line can recognise it but not python, it has to do with PYTHONPATH.. I'm just not sure how to proceed now, it gets very confusing from here. Note : I've also aliased my python version to 3.7.9 in bash. $ (env) python --version Python 3.7.9 -
Django ForeignKey serve nested objects with GET but accept id with POST request
I am new to Django. In my app, each Topic has Category fields. When fetching list of topics, it was serving id as category field like this: { id: 1, topic: "title", category: 1 } I added this to my serializer.py file: class TopicSerializer(serializers.ModelSerializer): category = CategorySerializer() class Meta: model = Topic fields = "__all__" Now I am able to receive the whole category object: { id: 1, topic: "title", category: { name: "Category name" }, } However, when adding a new topic, it is expecting a dictionary. I still want to be able to add a new topic by passing category id in the dictionary like this: { topic: "new topic title", category: 1 } How can I make it so that POST request accepts category field as id but still serves category object in GET request? Thanks. -
Do I need an nginx container inside my Kubernetes cluster to serve my static files if I am using Ingress-Nginx service on the cluster?
Might be a dumb question but I have a relatively simple Django App running in a docker container, also I have an Nginx container as a reverse-proxy serving my static files for the same app. Now, the question is, when I am to put the Django app inside a K8s cluster and spin up an Ingress-Nginx service, would I still need an Nginx container running inside the cluster to serve static files or I can use Ingress-Nginx for that? Thanks -
Django rest framework: serializing extra fields that depend on other state?
This question asks how to add an additional field to ModelSerializer. This answer says you can add a SerializerMethodField. But, how to implement a method field if the value of the call depends on some other parameter, like the request? -
Django error: NoReverseMatch at : I get this error
I have the following conceptual error which I am not undertstanding: Please have a look at the thrown error: NoReverseMatch at /watchlist Reverse for 'auction' with arguments '('',)' not found. 1 pattern(s) tried: ['(?P<auction_id>[0-9]+)$'] Request Method: GET Request URL: http://127.0.0.1:8000/watchlist This is my urls.py file: from django.urls import path from . import views urlpatterns = [ path("", views.index, name="index"), path("login", views.login_view, name="login"), path("logout", views.logout_view, name="logout"), path("register", views.register, name="register"), path("<int:auction_id>", views.auction, name="auction"), path("new", views.newItem, name="newItem"), path("watchlist", views.watchlist, name="watchlist"), path("addwatchList/<int:auction_id>", views.add_watchlist, name="add_watchlist"), path("remwatchList/<int:auction_id>", views.rem_watchlist, name="rem_watchlist"), ] And the views.py file fragment where the errors occurs is this: @login_required def watchlist(request): u = User.objects.get(username=request.user) return render(request, "auctions/watchlist.html", { "watcher": u.watchingAuction.all() }) Assigning the "watcher" variable makes the application brake and show the error message. Can you please help me out? Where is the conceptual mistake? Thnkass -
How does Django handles multiple request
This is not a duplicate of this question I am trying to understand how django handles multiple requests. According to this answer django is supposed to be blocking parallel requests. But I have found this is not exactly true, at least for django 3.1. I am using django builtin sever. So, in my code(view.py) I have a blocking code block that is only triggered in a particular situation. It takes a very long to complete the request for this case. This is the code for view.py from django.shortcuts import render import numpy as np def insertionSort(arr): for i in range(1, len(arr)): key = arr[i] j = i-1 while j >=0 and key < arr[j] : arr[j+1] = arr[j] j -= 1 arr[j+1] = key def home(request): a = request.user.username print(a) id = int(request.GET.get('id','')) if id ==1: arr = np.arange(100000) arr = arr[::-1] insertionSort(arr) # print ("Sorted array is:") # for i in range(len(arr)): # print ("%d" %arr[i]) return render(request,'home/home.html') so only for id=1 it will execute the blocking code block. But for other cases, it is supposed to work normally. Now, what I found is, if I make two multiple requests, one with id=1 and another with id=2, second request … -
installation de mysqlclient sur mon site en production
Salut j'essaie d'installer mysqlclient sur mon site développé avec django en production ,sur un hébergement offrant un cpanel comme o2switch, mais j'y arrive pas. J'ai essayé le pip install mysqlclient et j'ai cette erreur mais j'ai une erreur : Failed to build mysqlclient. Après beaucoup j'ai trouvé une autre façon de faire avec les fichiers mysqlclient-1.4.6-cp38-cp38-win32.whl mais j'ai l'erreur suivante: ERROR: mysqlclient-1.4.6-cp38-cp38-win_amd64.whl is not a supported wheel on this platform. Pouvez vous m'aider s'il vous plaît? Merci -
Deploy django app that uses docker run command
I have a Django app that I want to deploy on Heroku. The application calls the command docker run hello-world in views.py when the button is pressed. As far as I know, on Heroku you can set up a stack on Ubuntu or Docker. When I use Ubuntu, I install docker using heroku-buildpack-apt. Unfortunately I then get the following error: docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?. See 'docker run --help'. I tried using docker run -v /var/run/docker.sock:/var/run/docker.sock hello-world but to no effect. Aptfile uidmap iptables daemon apt-transport-https ca-certificates curl gnupg-agent software-properties-common http://security.ubuntu.com/ubuntu/pool/universe/d/docker.io/docker.io_19.03.8-0ubuntu1.20.04.1_amd64.deb When I try to dockerize the django app (and apply docker in docker), I have the same problem. I tested it locally. After typing django-compose up and clicking button, I get docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?. See 'docker run --help'. Dockerfile FROM python:3.8-buster ENV PATH="/scripts:${PATH}" ENV LD_LIBRARY_PATH=/usr/local/lib COPY ./requirements.txt /requirements.txt RUN apt-get update RUN pip install --upgrade pip RUN pip install -r /requirements.txt # install Docker RUN apt-get remove docker docker-engine docker.io runc RUN apt-get install -yq --no-install-recommends apt-utils RUN apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common RUN curl -fsSL … -
Django Ajax - Update table after submitting form
Good evening, inside my page there are two areas - one in which the form with the new data is submitted and a second one where all the entries should be displayed inside a table.. I'm still new to javascript, so I'm asking myself, wether it's possible to update the table with the new data after pressing the submit button (and without refreshing the whole page)!? models.py class AjaxTable(models.Model): first_name = models.CharField(max_length=25, null=False, blank=False) last_name = models.CharField(max_length=25, null=False, blank=False) age = models.IntegerField(default=0, validators=[MinValueValidator(1), MaxValueValidator(100)]) def __str__(self): return f"{self.first_name} {self.last_name}" views.py def javascript_ajax_table_update(request): qs_table = AjaxTable.objects.all() form = AjaxTableForm() data = {} if request.is_ajax(): form = AjaxTableForm(request.POST, request.FILES) if form.is_valid(): form.save() data['first'] = form.cleaned_data.get('first_name') data['last'] = form.cleaned_data.get('last_name') data['age'] = form.cleaned_data.get('age') data['status'] = 'ok' return JsonResponse(data) context = {'formset': form, 'qs_table': qs_table} return render(request, 'app_django_javascript/create/django_javascript_ajax_table_update.html', context) forms.py class AjaxTableForm(ModelForm): class Meta: model = AjaxTable fields = '__all__' template.html <div class="grid-container"> <div class="cnt-create"> <div class="card"> <div class="card-body"> <form action="" method="post" autocomplete="off" id="post-form" name="post-form"> {% csrf_token %} <div class="div-post-input-flex"> <div class="div-post-input"> <label>First Name</label><br> {{ formset.first_name }} </div> <div class="div-post-input"> <label>Last Name</label><br> {{ formset.last_name }} </div> <div class="div-post-input"> <label>Age</label><br> {{ formset.age }} </div> </div> <div class="div-post-input"> <button class="btn btn-success" type="submit"> Save </button> </div> </form> </div> … -
'RiskData' object has no attribute 'device_data_captured' using Python Braintree
For a Customer I created a project using Django. I implemented some RESTful API for Client's mobile apps. We integrated Braintree to have a Payments Gateway. Everything worked fine for years.. At the moment, the mobile apps haven't been updated for several months. Some mouths ago, Server side, we upgraded Python and Django version (as also Braintree SDK to the version 4.5.0) and inexplicably, from 2, 3 days the payments using credit cards getting in fails (using PayPal works fine. In theory, the money are withdrawn by the Customer cards but the flow mobile-server it's broken now so, server side, I'm not able to complete Braintree transaction flow. In particular, when I try to call this method to validate the transaction (as described into Braintree documentation) result = gateway.transaction.sale({ "amount": orderPrice, "order_id": str(order.uuid), "payment_method_nonce": nonce_payment, "customer": GatewayManager._generateCustomerInfo(order.owner), "options": { "store_in_vault_on_success": STORE_IN_VAULT_ON_SUCCESS, "submit_for_settlement": SUBMIT_FOR_SETTLEMENT, } }) I obtain this error: 'RiskData' object has no attribute 'device_data_captured' I'm not able to understand the reason... Why from some days it's broken? What's we missed or what's we need to do?