Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django error while saving to database : IntegrityError at / NOT NULL constraint failed: kullanici_arizamodel.p_id_id
I have two models with OneToMany relation between them. personelModel and arizaModel. When I click the save button, I get the following error: "IntegrityError at / NOT NULL constraint failed: kullanici_arizamodel.p_id_id" personelModel saved but arizaModel not saved in database table. I want both models to be saved in database I want help. /my english is not good i am sorry about that/ models.py: from email.policy import default from tabnanny import verbose from django.db import models # Create your models here. class personelModel(models.Model): p_sicil = models.CharField(max_length=8, verbose_name='Personel Sicili') p_isim = models.CharField(max_length=50, verbose_name='Personel Adı') p_bilgisayar_adi = models.CharField(max_length=4, verbose_name='Bilgisayar Adı') p_durum = models.BooleanField(default=True, verbose_name='Personel Durumu') class Meta: verbose_name = "Personel" verbose_name_plural = "Personeller" def __str__(self): return self.p_sicil class arizaModel(models.Model): p_id = models.ForeignKey(personelModel, on_delete=models.CASCADE) a_aciklama = models.CharField(max_length=100, verbose_name='Arıza Açıklama') a_acilma_tarihi = models.DateTimeField(auto_now_add=True, verbose_name='Açılma Tarihi') a_durum = models.BooleanField(default=True, verbose_name='Arıza Durumu') a_kapanma_tarihi = models.DateTimeField(auto_now_add=True, verbose_name='Kapanma Tarihi') class Meta: verbose_name = "Arıza" verbose_name_plural = "Arızalar" def __str__(self): return self.a_aciklama views.py from django.shortcuts import render from django.urls import reverse_lazy from kullanici.forms import PersonelBilgileriForm, ArizaBilgileriForm def kullaniciArizaKaydetView(request): form1 = PersonelBilgileriForm(request.POST, prefix='personel_bilgileri') form2 = ArizaBilgileriForm(request.POST, prefix='ariza_bilgileri') if request.method == 'POST': if form1.is_valid() and form2.is_valid(): personel_bilgileri = form1.save() ariza_bilgileri = form2.save() return render(request, 'kullanici.html',{'PersonelBilgileriForm': form1, 'ArizaBilgileriForm': form2}) forms.py from django import … -
Is there a way I can get a list of all the items with balance variable in django
I have created an API that is being called by my react frontend. So the problem is this I have a viewset that shows a list of all customers in the database which works perfectly. I have also created a retrieve method that shows individual customer details and all the orders purchased. In this retrieve method, I have a variable that shows the balance for the customer. My question is, is there a way I can get a List of all customers with a balance that is greater than 0 and lower than 0 Here is my viewset class CustomerViewSet(viewsets.ViewSet): authentication_classes = [JWTAuthentication] permission_classes = [IsAuthenticated] def list(self, request): customer = Customer.objects.all() serializer = CustomerSerializer(customer, many=True, context={"request": request}) response_dict = {"error": False, "message": "All Customers List Data", "data": serializer.data} return Response(response_dict) def create(self, request): try: serializer = CustomerSerializer(data=request.data, context={"request": request}) serializer.is_valid(raise_exception=True) serializer.save() dict_response = {"error": False, "message": "Customer Data Stored Successfully"} except: dict_response = {"error": True, "message": "Phone Number Exists In Database, Fill All Fields"} return Response(dict_response) def retrieve(self, request, pk=None): queryset = Customer.objects.all() customer = get_object_or_404(queryset, pk=pk) serializer = CustomerSerializer(customer, context={"request": request}) serializer_data = serializer.data # Accessing All the Orders Details of Current Customer orders_details = Orders.objects.filter(customer_id=serializer_data["id"]).order_by('-id') orders_details_serializers = … -
How to save file in two different directories after uploading a file in Django
I am working in Python Django with version 4.0.4. I have stucked in a situation where I want to save a file in two different directories at the same time when user browse the file and click on upload button. I am already saving the file in one directory, now I want to save the same file in two different directories. Kindly help me to resolve this issue: Here is the code: views.py: def upload(request): if request.method=="POST": uploaded_file = request.FILES['file extension'] fs = FileSystemStorage() fs.save(uploaded_file.name, uploaded_file) print(upload_file.name) print(upload_file.size) return render(request, 'abc.html') abc.html: <form method="post" enctype="multipart/form-data"> {% csrf_token %} <input type="file" name="xyz"> <button type="submit"> upload file </button> </form> urls.py: from django.conf import settings from django.conf.urls.static import static if setting.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) settins.py: MEDIA_ROOT= '/home/abc/directory1/foldername1' MEDIA_URL = 'abc/' #MEDIA_ROOT_1= '/home/abc/directory2/foldername2' #MEDIA_URL_1 = 'abc2/' Here are the methods for which I am saving the file in a single directory, but when I apply the same methods with different objects It doesn't bother the MEDIA_ROOT_1 and doesn't save the file in this directory. It always save the file of the given path in MEDIA_ROOT. Kindly help me to save this file in different directories -
i try to run django project inside google cloud VM instance and i am receiving error ModuleNotFoundError: No module named '_bz2'
my project is working locally fine but when i clone my project from git inside google cloud VM and try to run the project without any database configuration also i am receiving error:ModuleNotFoundError: No module named '_bz2' and it is comming from pandas File "/usr/local/lib/python3.8/bz2.py", line 19, in from _bz2 import BZ2Compressor, BZ2Decompressor ModuleNotFoundError: No module named '_bz2' can any one tell me the solution for it -
Django JavaScript Array
I have the following JS code: data: [40, 60, 30, 65, 60, 95, 90, 100, 96, 120, 105, 134] This represents a curve in a graph on HTML. I want to draw a line (same value 12 times), and this value is brought by Django. The value is 100. I tried the following: in Django: limit = [mylimit for i in range(1,12)] in JS: data: {{ limit }} didn't work. I even tried creating the list manually on Django: limit = f"{limit}, {limit}, ...." and doing this on JS: data: [{{ limit }}] and nothing works. My goal is to take whatever limit I have (aka: 100), and have the following JavaScript: data: [100, 100, 100..... -
How to write the json for patch on Django REST Framework
I have PATCH button form on ModelViewSet class CompanyViewSet(viewsets.ModelViewSet): serializer_class = s.CompanySerializer queryset = m.Company.objects.all() def patch(self, request, id, format=None): print(id) Now I try to modify the existing data id = 1 So I write this in textarea and push PATCH button. { "id":1, "name": "" } However , there comes error like patch() missing 1 required positional argument: 'id' Maybe my json is wrong?? How can I do PATCH? patch() missing 1 required positional argument: 'id' -
Axios giving 401 (Unauthorized). I am trying to get userdata through react frontend passed to DRF Social Oauth2. Same is working on POSTMAN
Below are the two files LoginScreen.JS which has a submit handler that submits the input. Here we import the axios instance from login.JS. I have also attached the same working example from PostMan. Below are the two files LoginScreen.JS which has a submit handler that submits the input. Here we import the axios instance from login.JS. I have also attached the same working example from PostMan. login.js const baseURL='http://127.0.0.1:8000/'; const axiosInstance = axios.create({ baseURL: baseURL, timeout: 5000, headers: { 'Content-Type': 'application/json', accept: 'application/json' }, }); export default axiosInstance LoginScreen.js const submitHandler = (e) => { e.preventDefault() axiosInstance .post(`auth/token/`,{ username: email, password: password, grant_type: 'password', client_id: 'Vqvt1yp2HahF8KgwOS3BrWaCUX8ViDGCrn3VfJkz', client_secret: 'Vqvt1yp2HahF8KgwOS3BrWaCUX8ViDGCrn3VfJkz' }) .then((res) => { localStorage.setItem('access_token', res.data.access); localStorage.setItem('refresh_token', res.data.refresh); }); }; -
generating tokens and sending them to users
I am trying to implement the account activation and password reset functionalities and I would like to review the theory. I currently have 2 tables, user and token table. The user signs up. I save the user in the db, generate token and send it via email. So here's how I am tackling the problem: I am creating a 16bytes token and using this to create the link e.ghttp://localhost:1200/api/activation/<token>. However, in the db I am storing the hashed token (hashed with sha256). Then, theoretically, when the user clicks on the link, I perform sha256 on the token and see if it matches with the one stored in the database, right? I think the reason it is recommended to store the hash inside the db is because if the attacker has access to the db, he cannot impersonate the user (it still needs the original token), right? -
django-plotly-dash multi session on CPU intensive pages
Running - django-plotly-dash I have multipole python pages, the issue is that when I am loading one of the pages while it is running some calculations, I can not run the same page or other pages from a different session, and the webserver is not responding for other users. if I look at the runserver output, it is busy rendering the first request only. -
PUT or PUSH for modifying the existing data?
I have viewset, class CompanyViewSet(viewsets.ModelViewSet): serializer_class = s.CompanySerializer queryset = m.Company.objects.all() Which shows the view on /api/companys There is a button for POST I can add the new data from this form. Now I want to modify the existing data. I have basic questions. PUSH can modify the data? or PUT should be implemented? How PUT can be implemented for ModelViewSet? -
Custom django permissions for group chats?
I have a custom group model like this: class MyGroup(models.Model): name = models.CharField(max_length=200,null=True,blank=False,default="Group name") members = models.ManyToManyField(get_user_model(), blank=True, related_name="grpmembers") created_by = models.ForeignKey(get_user_model(), on_delete=models.DO_NOTHING, null=True, blank=False, related_name="createdby+") created_at = models.DateTimeField(editable=False) It works, it's fine, I override the save method in django admin so the created_by will point to the logged in user on save. Problem #1 Even if you are the creator of the group, you can select yourself to either be in- or be removed from the group which kinda looks silly. I'm thinking of solving this by saying the user can view the group if they're in members or created_by. Problem #2 Custom permission. I want to have some permissions, like: Can view the group: which means the user is either the creator or is in the members list Can edit the group: which means the user is the creator(can edit their own) or is staff(can edit anyone's stuff) or is superuser(root) I can write it down and imagine how it would work, but I have no idea how to implement these. I've found some ways, like creating a Meta and defining permissions there and also making the permissions as def(/functions), but how could I access the currently logged … -
How to do right model for tree-based view?
I need to make tree of employees fro database. If i have this model: class Employee(models.Model): name = models.CharField(max_length=100) position = models.CharField(max_length=100) hired_at = models.DateField(auto_now=True) salary = models.DecimalField(max_digits = 9, decimal_places= 2) boss = models.ForeignKey('self', null=True,blank=True, on_delete=models.CASCADE) def __str__(self): return f'<{self.pk}> {self.name} - {self.position}' Can I iterate in template and make tree-based structure or I need another configuration of my Model? -
Django join fields in queryset
Is it possible to join common fields in different queryset. I have day_name = Monday in two queryset. I want to combine it into one. The reason i wanted to do it because when mapping it on frontend react. I want to see only one Monday , not two mondays. [ { "day__day_name": "Monday", "subject_name__subject_name": "Maths" }, { "day__day_name": "Monday", "subject_name__subject_name": "English" } ] I want to join these both "Monday" so that i can only return it as one "Monday" instead of two or more -
How to save a field from another model to a variable NOT A FIELD
I have a model called Actual: # Actual parts table class Actual(models.Model): vendor = models.ForeignKey(Vendor, on_delete=models.CASCADE, verbose_name="Vendor name", related_name="actualvendor") number = models.CharField("External part number", max_length=32, unique=True, blank=True, null=True) description = models.CharField(max_length=64, blank=True) pq = models.DecimalField(max_digits=7, decimal_places=2, default=1) mrrp = models.DecimalField(max_digits=10, decimal_places=2) # Model metadata class Meta: unique_together = ["vendor", "number"] verbose_name_plural = "actual external parts" # Display below in admin def __str__(self): return f"{self.number}" I also have another model called Offer: class Offer(models.Model): sync_id = models.ForeignKey(Sync, on_delete=models.CASCADE, verbose_name="Internal part number", related_name="part") discount = models.DecimalField(max_digits=3, decimal_places=2, default=0) moq = models.DecimalField(max_digits=4, decimal_places=2, default=1) status = models.CharField(max_length=20, choices=OFFERSTATUS_CHOICES, default=1) actual = models.OneToOneField(Actual, on_delete=models.CASCADE) # Display something in admin def __str__(self): return f"Offer {self.id} for {self.sync_id}" # Calculate the price def price(self): return self.actual.mrrp * (1-self.discount) I am trying to calculate the 'price' using 'mrp' But 'mrrp' is from another model. I am able to do so with the code I've attached but as you can see in the django admin, the 'actual' shows up as a field. First, I do not need it to be a field. I only need 'Actual' to be a variable that stores the value of 'mrrp'. Second, I want it to auto-select the corresponding value based on the … -
Get mime type of InMemoryUploadedFile without extention in Python
I'm trying to get the mime type of for example a InMemoryUploadedFile JavaScript file without knowing the file extention in Python Currently i check my InMemoryUploadedFile with in_memory_file.content_type which returns application/octet-stream for a JavaScript file after that i use the Magic lib magic.Magic(mime=True).from_buffer(in_memory_file.read()) Which returns text/plain. When uploading a file that contains the .js extention i'm getting the right mime type "text/javascript" -
How to refer a html file in templates subdirectory in <a href='url' tag in Django html template
I am quite new to django, the below is my project templates folder structure templates index.html about.html contact.html \student index.html \Attendance attendance.html .... \Exams results.html exam1.html ..... \Misc \teachers index.html \hrms adminlogin.html payslip.html principallogin.html .... .... urs.py: urlpatterns = [ path('admin/', admin.site.urls), path("",home,name="home"), views.py: def home(request): return render(request, 'index.html') till now this is working fine, if I index.html: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <div class="u-custom-menu u-nav-container"> <ul class="u-nav u-spacing-30 u-unstyled u-nav-1"><li class="u-nav-item"><a class="u-border-0 u-border-no-bottom u-border-no-left u-border-no-right u-border-no-top u-button-style u-nav-link u-text-active-palette-1-base u-text-grey-90 u-text-hover-palette-1-base" href="{% url 'home' %}" style="padding: 20px 5px;">Home</a> </li><li class="u-nav-item"><a class="u-border-0 u-border-no-bottom u-border-no-left u-border-no-right u-border-no-top u-button-style u-nav-link u-text-active-palette-1-base u-text-grey-90 u-text-hover-palette-1-base" href="about.html" style="padding: 20px 5px;">About</a> </li><li class="u-nav-item"><a class="u-border-0 u-border-no-bottom u-border-no-left u-border-no-right u-border-no-top u-button-style u-nav-link u-text-active-palette-1-base u-text-grey-90 u-text-hover-palette-1-base" href="contact.html" style="padding: 20px 5px;">Contact</a> </li><li class="u-nav-item"><a class="u-border-0 u-border-no-bottom u-border-no-left u-border-no-right u-border-no-top u-button-style u-nav-link u-text-active-palette-1-base u-text-grey-90 u-text-hover-palette-1-base" href="" style="padding: 20px 5px;">Login</a> <div class="level-2 u-nav-popup u-white u-nav-popup-1"> <ul class="u-h-spacing-20 u-nav u-popupmenu-items u-unstyled u-v-spacing-10 u-nav-2"> <li class="u-nav-item"><a class="u-button-style u-nav-link" href="/hrms/adminlogin.html">Administrator</a></li> <li class="u-nav-item"><a class="u-button-style u-nav-link" href="/hrms/mangementlogin.html">Management</a></li> <li class="u-nav-item"><a class="u-button-style u-nav-link" href="/hrms/principallogin.html">Principal</a></li> <li class="u-nav-item"><a class="u-button-style u-nav-link" href="/teacher/index.html">Teacher</a></li> <li class="u-nav-item"><a class="u-button-style u-nav-link" href="/student/index.html">Student</a></li> </ul> </div> </li> </ul> </div> </body> </html> We are getting the following error message when we run the project, need help … -
POST request works or not depending on user login, Django REST framework
Django and django REST framework. From template javascript, I make new database entry with this post. axios.post(`http://localhost:8000/api/companys/`,{}) It works well at first, just using REST Framework default CRUD system. class CompanyViewSet(viewsets.ModelViewSet): serializer_class = s.CompanySerializer queryset = m.Company.objects.all() However, when user log-in django, It returns the 403 permission. After log-out it works successfully. It is quite mysterious, anonymous user successs, but login user doesn't. How can I solve this? My REST_FRAMEWORK setting is like this below. REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.TokenAuthentication', 'rest_framework.authentication.BasicAuthentication', 'rest_framework.authentication.SessionAuthentication', ), 'DEFAULT_PERMISSION_CLASSES': ( ), 'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend'] } -
How to create in secondary database using Django
dbrouter.py class DbRouter(object): mhris = [HrUserMstr] profocus_db = [VendorEntry, ApVendorMt, ApVendorDt, ApVendorCertificateDt] apps_ppl = [] def db_for_read(self, model, **hints): if model in self.profocus_db: return 'PROFOCUS_DB' elif model in self.apps_ppl: return 'APPS_PPPL' elif model in self.mhris: return 'MHRIS' else: return 'default' def db_for_write(self, model, **hints): if model in self.profocus_db: return 'PROFOCUS_DB' elif model in self.apps_ppl: return 'APPS_PPPL' elif model in self.mhris: return 'MHRIS' else: return 'default' def allow_migrate(self, db, app_label, model_name=None, **hints): if model_name in self.profocus_db: return 'PROFOCUS_DB' elif model_name in self.apps_ppl: return 'APPS_PPPL' elif model_name in self.mhris: return 'MHRIS' else: return 'default' models.py class ApVendorDt(models.Model): certificate = models.ForeignKey(ApVendorCertificateDt, on_delete=models.CASCADE) vendor_code = models.CharField(max_length=30, default='') vendor_doc = models.FileField(upload_to='vendor_doc/') created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) def __str__(self): return self.vendor_id class Meta: db_table = 'APVENDOR_DT' db_for_write and db_for_read functions are working fine but allow_migrate is not working. I'm trying to create a new table using django model it is creating table in default database But I want to create table in only profocus_db which is my secondary database. django 4.0.1 -
Is there a way to remove email from being displayed in JWT dajngo?
I have this simple example in Django to create JWT using djangorestframework-jwt this is my code: user_payload = TbaleUsers.objects.get(email="test@gmail.com") encoded_payload = jwt_payload_handler(user_payload) access_token = jwt.encode(encoded_payload, SECRET_KEY, ALGORITHM) When I get the access token and I go to this website https://jwt.io/ and place it there it shows me the user id, username and email I want to remove the email from being shown Is there a way to do that? -
Query Local serial ports using the Hosted Django Website in IIS
I have a code for querying and listing serial ports on my local machine.Now my problem is when I host the app in the IIS because it now only lists the serial ports in that server machine. Is there a way I can twerk this to list the ports that are in my local machine too? Or am I doing the wrong thing? here is the code. def retrieve_ports(): """ Lists serial port names :raises EnvironmentError: On unsupported or unknown platforms :returns: A list of the serial ports available on the system """ if sys.platform.startswith('win'): ports = ['COM%s' % (i + 1) for i in range(256)] elif sys.platform.startswith('linux') or sys.platform.startswith('cygwin'): # this excludes your current terminal "/dev/tty" ports = glob.glob('/dev/tty[A-Za-z]*') elif sys.platform.startswith('darwin'): ports = glob.glob('/dev/tty.*') else: raise EnvironmentError('Unsupported platform') result = [] for port in ports: try: s = serial.Serial(port) s.close() result.append(port) except (OSError, serial.SerialException): pass print("available ports===",result) return result -
How to find if two XML files are same and if not will I be able to Identify the mismatched fields using python?
The given below is my current code from lxml import etree tree1 = etree.parse('sample1.xml') tree2 = etree.parse('sample2.xml') set1 = set(etree.tostring(i, method='c14n') for i in tree1.getroot()) set2 = set(etree.tostring(i, method='c14n') for i in tree2.getroot()) print(set1 == set2) Here it just prints "True" if the xml files are same and "False" if they are not equal. What I am trying to do is to find the fields or places where the data is showing mismatch. both the files will be equal eventually. But if the files have any difference in the data's, I need to know where all there is differences. -
Integrate Laravel Spark with Auth0 and Django
We are planning to use Laravel Spark to manage payments and subscriptions for our Sass service though our django project secured by Auth0. Could you kindly assist me to figure out the best way to connect Laravel Sparks with Django and Auth0? -
How the request.data can used for switching the django class view?
I am trying to use single API to call the different class based view. Actually planning to solve this by using another function. Is this pythonic way? My Urls.py from django.urls import path from masterdata import views from rest_framework.urlpatterns import format_suffix_patterns urlpatterns = [ path('AAA/', views.AAAList.as_view()), path('AAA/<str:pk>/', views.AAADetails.as_view()), path('BBB/<str:pk>/', views.BBBList.as_view()), path('BBB/<str:pk>/', views.BBBDetails.as_view()), ] urlpatterns = format_suffix_patterns(urlpatterns) my Views.py class AAAList(APIView): "some operation" class AAADetails(APIView): "some operation" class BBBList(APIView): "some operation" class BBBDetails(APIView): "some operation" My actual need is I want to switch these class using single Url with passing the body data in the method. url looks like, path("",views."somefunction or class") How can I achieve this? i try to solve this by an creating function in views.py def switcher(request): if request.GET.get("body param")==AAA: return AAA.as_view()(request) elif request.GET.get("body param")==AAA: return BBB.as_view()(request) -
how to use 1 master(page or model.Model) for many catigories(page)?
i wanna get somethink like this but i have no idea how 2 do it in wagtail(1 child cant have more then 1 parent), how 2 fix it? I dont wanna have 3 master pages in admin panel well, im newbie in wagtail, i know about snippets, but i need master page. I know how 2 do it in django, but have no idea when using wagtail. class Master(Page): name = models.CharField(max_length=200) contacts = RichTextField( blank=True, null=True, ) image = models.ForeignKey('wagtailimages.Image', blank=True, null=True, on_delete=models.SET_NULL, related_name='+', verbose_name=) content_panels = Page.content_panels + [ FieldPanel('name'), FieldPanel('contacts'), FieldPanel('image'), ] class ProductsIndexPage(Page): intro = RichTextField(blank=True) content_panels = Page.content_panels + [ FieldPanel('intro', classname="full"), MultiFieldPanel([ InlinePanel('products_sell', label="Product")], heading="Products",), MultiFieldPanel([ InlinePanel('training', label="Training")], heading="Training", ), ] class Training(AbstractProducts): product = ParentalKey( 'ProductsIndexPage', on_delete=models.CASCADE, related_name='training' ) -
Getting 'Cannot use MongoClient' exception when refreshing django API request
I currently have an AWS EC2 instance running that is running a web server using Apache (httpd) to deploy the server in the instance. The project uses the Django, Djongo, and Django Rest Framework python libraries. It works initially as it gives back an API response via JSON. However, when making another API call, it comes out with the following exception: DatabaseError at /profile/7/ No exception message supplied Environment: Request Method: GET Request URL: https://[redacted]/profile/7/?format=json Django Version: 3.2.16 Python Version: 3.7.10 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'api'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 808, in __iter__ yield from iter(self._query) File "/usr/local/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 166, in __iter__ for doc in cursor: File "/usr/local/lib64/python3.7/site-packages/pymongo/cursor.py", line 1248, in next if len(self.__data) or self._refresh(): File "/usr/local/lib64/python3.7/site-packages/pymongo/cursor.py", line 1165, in _refresh self.__send_message(q) File "/usr/local/lib64/python3.7/site-packages/pymongo/cursor.py", line 1053, in __send_message operation, self._unpack_response, address=self.__address File "/usr/local/lib64/python3.7/site-packages/pymongo/_csot.py", line 105, in csot_wrapper return func(self, *args, **kwargs) File "/usr/local/lib64/python3.7/site-packages/pymongo/mongo_client.py", line 1335, in _run_operation retryable=isinstance(operation, message._Query), File "/usr/local/lib64/python3.7/site-packages/pymongo/_csot.py", line 105, in csot_wrapper return func(self, *args, **kwargs) File "/usr/local/lib64/python3.7/site-packages/pymongo/mongo_client.py", line 1441, in _retryable_read server = self._select_server(read_pref, session, address=address) File "/usr/local/lib64/python3.7/site-packages/pymongo/mongo_client.py", line 1247, in _select_server topology = self._get_topology() File "/usr/local/lib64/python3.7/site-packages/pymongo/mongo_client.py", …