Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Error when uploading image, 'This Field is Required'
I am using Django's built in class based views, and am getting an error when I am trying to add a file through the CreateView. I am able to add images through the admin, and when I remove the image field, the error goes away, so I am fairly certain that the issue lies in allowing images to be uploaded via the CreateView. I should be using it 'out of the box' but it still is not working. Here is my views.py: class AddImage(generic.CreateView): model = Picture fields = ['image', 'name', 'desc', 'tags', 'original_author', 'author_url'] template_name = 'pics/add_pic.html' success_url = reverse_lazy('dashboard') def form_valid(self, form): form.instance.user = self.request.user super(AddImage, self).form_valid(form) return redirect('home') models.py: class Picture(models.Model): image = models.ImageField(upload_to='maps/uploads/%Y-%m-%d/') name = models.CharField(max_length=255) desc = models.TextField() tags = TaggableManager(blank=True) original_author = models.CharField(max_length=255, blank=True, null=True) author_url = models.URLField(blank=True, null=True) user = models.ForeignKey(User, on_delete=models.CASCADE) def __str__(self): return self.name HTML: {% extends 'pics/base.html' %} {% block content %} <div class="add-image"> <h2>Add an image</h2> <form method="post" enctype="multipart/form-data"> {% csrf_token %} {{ form.as_p }} <button type="submit" class="btn btn-primary">Add Image</button> </form> </div> {% endblock %} Those are the only places that I think would have issues, as I am not using forms. But I can provide more code than … -
How to take field value in a serializer class from another model in DRF
First model class Navigation(models.Model): title = models.CharField(max_length=255, blank=True, null=True) page_id = models.IntegerField(blank=True, null=True) Second Model class PagePlatform(models.Model): page = models.ForeignKey(Page, models.DO_NOTHING, blank=True, null=True) Third Model class Page(models.Model): name = models.CharField(max_length=255) Serializer class class NavSerializer(serializers.ModelSerializer): page_id = GetPageId(read_only=True) class Meta: model = Navigation fields = ['title','page_id'] I tried by creating two Serializer class and combing them into one but not succeeded. class NavPageId(serializers.ModelSerializer): class Meta: model = Navigation fields = ['page_id'] class GetPageId(serializers.ModelSerializer): num = NavPageId(read_only=True) page = serializers.SerializerMethodField() def get_page(self,instance): data = PagePlatform.objects.filter(page=num.data) return data class Meta: model = PagePlatform fields = ['id','page','num'] [what I am trying to achieve is] In NavSerializer the page_id has to be taken from Navigation Table and checked in the PagePlatform Table. Finally, take the page platform id. -
Are my server files safe? I keep getting weird errors that reference an unknown domain
I'm running a Dockerized Django application with NGINX in a VPS and I keep getting these strange requests which results in an error. This is the sentry error log: Invalid HTTP_HOST header: 'check.best-proxies.ru'. You may need to add 'check.best-proxies.ru' to ALLOWED_HOSTS. /azenv.php django.security.DisallowedHost I don't even understand why its an "Invalid HTTP_HOST header" error. Does this mean he has access to my Django code? This has been happening for a few days now. -
Error caused by total_likes in Function Django
I have been able to add a like button which is working but when I add total_likes context everything doesn't work. The total_likes have been hashtagged/commented in the LikeView. I want to know why the hashtagged/commented part is wrong and how to resolve it Here is the views.py class PostDetailView(DetailView): model = Post template_name = "post_detail.html" def get_context_data(self, *args, **kwargs): context = super(PostDetailView, self).get_context_data() stuff = get_object_or_404(Post, id=self.kwargs['pk']) total_likes = stuff.total_likes() liked = False if stuff.likes.filter(id=self.request.user.id).exists(): liked = True context["total_likes"] = total_likes context["liked"] = liked return context def LikeView(request): post = get_object_or_404(Post, id=request.POST.get('id')) # stuff = get_object_or_404(Post, id=self.kwargs['pk']) # total_likes = stuff.total_likes() liked = False if post.likes.filter(id=request.user.id).exists(): post.likes.remove(request.user) liked = False else: post.likes.add(request.user) liked = True context = { # 'total_likes': total_likes, 'liked': liked, 'post': post } if request.is_ajax: html = render_to_string('like_section.html', context, request=request) return JsonResponse({'form': html}) -
Create moodle user in django
I want to create my moodle's users via django using web services (without ssl verification). I have tried this https://github.com/mrcinv/moodle_api.py but to no avail. -
Django page, losing ChartJs rendered graph when I refresh page
I've successfully rendered the graph in my homepage path, but whenever I refresh the page, I lose whatever was rendered and I'm not 100% sure why. # urls.py urlpatterns = [ path('', chartData.homepage, name='homepage'), path('chart/', chartData.chart, name='chart'), path('api/chart/data/', chartData.as_view()), ] I'm not sure where the issue could be coming from and I'm fairly new to Ajax, so I believe I am missing something. <form autocomplete="off" action="" method="GET"> <div class="autocomplete"> <input id="myInput" type="text" name="Item" placeholder="Enter Item"> </div> <input type="submit" id="submitBtn" value="Search"> </form> <div class="chart-container"> <canvas id="myChart"></canvas> </div> <script type="text/javascript"> var endpoint = 'api/chart/data/' var dataset = [] var labels = [] $('#submitBtn').click(function(e){ e.preventDefault(); var item = $('#myInput').val(); $('#myInput').val(''); window.history.pushState("object or string", "Title", "/?Item" + item); $.ajax({ url: endpoint, method: "GET", dataType: "text", success: function(){ $.ajax({ method: "GET", url: endpoint, data:{ 'item': item, }, success: function(data){ console.log(itemName) labels = data.labels dataset = data.dataset var ctx = document.getElementById('myChart').getContext('2d') var chart = new Chart(ctx, { type: 'line', data: { labels: labels, datasets: [{ backgroundColor: 'rgb(255, 99, 132)', borderColor: 'rgb(255, 99, 132)', data: dataset, fill: false, }], }, options: { responsive: true, maintainAspectRatio: false, } }) }, error: function(error_data){ console.log("error") console.log(error_data) } }) } }) }) </script> <!--JavaScript file for autofill functionality in search bar--> … -
timezone date to python date
Hi i am creating ics file for calendar invitation, as far as i see that if i dont put time zone some emails may become conflict, i have checked working ics files from zoom and i see that they put BEGIN:VTIMEZONE TZID:Turkey Standard Time BEGIN:STANDARD DTSTART:16010101T000000 TZOFFSETFROM:+0300 TZOFFSETTO:+0300 END:STANDARD END:VTIMEZONE now i translated this to code like timezone = Timezone() timezone.add('TZID','Turkey Standard Time') timezoneStandard = TimezoneStandard() timezoneStandard.add('TZOFFSETFROM', timedelta(hours=3)) timezoneStandard.add('TZOFFSETTO', timedelta(hours=3)) timezoneStandard.add('DTSTART','16010101T000000') <==== PROBLEM IS HERE timezone.add_component(timezoneStandard) cal.add_component(timezone) But i dont know to translate 16010101T000000 , i am getting error You must use datetime, date, timedelta -
Django form "passwords do not match" but they do
I struggled for a while in order to get the error to render on template and now I have I cant get rid of it and I get the validation error no matter what passwords I use. Even if password and confirm password are both "a" it throws! {% block content %} <div id="register-form"> <form method='post'> {% csrf_token %} {% for field in form %} <div class="register-field"> {{field}} </div> {% endfor %} <p>{{ form.password.errors.as_text }}</p> <button id="register-button" type='submit' value='Save'>Register</button> <button id="already-registered" action="{% url 'home' %}">Already registered?</button> </form> </div> {% endblock %}} model form def clean_password(self): """checks users passwords match in form and renders error if not""" password = self.cleaned_data.get("password") confirm_password = self.cleaned_data.get("confirm_password") if password != confirm_password: raise forms.ValidationError("Passwords must match.") return password -
Fixing Error in Django Rest Framework Model Serializer Related Primary Key Queryset
I feel like I'm chasing my tail here and so I've come to your fine folks to help me understand where I've screwed up and why my thinking on this must be flawed in some way. I'm writing an API in DRF and while it doesn't have a lot of tables in the DB, there are many to many relationships in the DB which makes it feel complicated, or at least it makes it difficult to just view the db tables and intuitively understand what's related. First my model. I'm getting this when attempting to POST a new object to the jobs model. I'm needing to validate that the requesting worker has the permission to create a job with the related target and workergroup Models: class Workers(models.Model): class Meta: ordering = ['id'] workerid = models.CharField(max_length=16, verbose_name="Worker ID", unique=True, default="Empty") customer = models.ForeignKey(Customers, on_delete=models.DO_NOTHING, default=1) workername = models.CharField(max_length=64, verbose_name="Worker Friendly Name", default="") datecreated = models.DateTimeField(auto_now_add=True) awsarn = models.CharField(max_length=60, verbose_name="ARN Name of Worker", blank=True, null=True) customerrights = models.ManyToManyField(Customers, related_name="access_rights", default="") class Targets(models.Model): class Meta: ordering = ['id'] customer = models.ForeignKey(Customers, on_delete=models.SET_NULL, default=1, null=True) friendly_name = models.CharField(max_length=70, verbose_name="Target Friendly Name", unique=False) hostname = models.CharField(max_length=120, verbose_name="Target Hostname", default="") ipaddr = models.GenericIPAddressField(protocol='both', unpack_ipv4=True, default="", null=True) … -
How to choose the correct Amazon-EC2 AMI for a Dockerized Django application?
I am trying to use an EC2 instance to host a Dockerized Django application with a postgresql db, and I am having trouble understanding how one would choose an appropriate AMI for this instance. For starters, does the OS of the instance matter? I thought the point of Dockerizing an application was so that it can run on any environment. Once the OS is chosen, how would one decide between the remaining choices? Here is an example of some of the options Thanks! -
How to save created json file in Django storage
I want to save an error.json in the django storage system. For this I defined a custom FileStorageSystem fs = FileSystemStorage(location='/uploads/products/error_logs') fn = datetime.datetime.now().strftime('%Y-%m-%d') + '_' + get_random_string(15) + '.json' Later in my view.py I create a new json file with some arrays and try to save this file in my storagesystem. with open(fn,'w', encoding='utf-8') as jfile: myFile = File(jfile) json.dump(f, myFile, ensure_ascii=False, indent=4) fs.save(fn,myFile) This doesn't work. I receive the error message: UnsupportedOperation at /produkte/ not readable fs.save(fn,myFile) … ▼ Local vars Variable Value f [{'error_description': 'Zeitkonflikt', 'error_line': 1, 'error_line_excel': 2, 'try': 'Es sind bereits Einträge vorhanden, die zu dieser Zeit Gültigekeit ' 'besitzen'}] fn '2020-05-20_aFqOyrfbzzuOKzR.json' form <UploadForm bound=True, valid=True, fields=(upload_file)> fs <django.core.files.storage.FileSystemStorage object at 0x050D3050> jfile <_io.TextIOWrapper name='2020-05-20_aFqOyrfbzzuOKzR.json' mode='w' encoding='utf-8'> myFile <File: 2020-05-20_aFqOyrfbzzuOKzR.json> request <WSGIRequest: POST '/produkte/'> What did I miss? -
Can I pass context variables from a GET request to POST request in same Django view function?
I have a Django view function that starts as a GET request, uses jQuery Autocomplete to find a value, then (hopefully) passes that value to a form with a POST request. How do I access that value on the POST side? Here's the relevant portion of code I have so far: def assign_terms(request, session_uuid): ctx = {} if request.method == 'GET': url_parameter = request.GET.get('q') # Some other stuff if request.is_ajax(): html = render_to_string( template_name='ExifReader/assign_terms-partial.html', context={'artists': artists} ) data_dict = {'html_from_view': html} ctx["artists"] = artists return JsonResponse(data=data_dict, safe=False) context = {'ctx':ctx} return render(request, 'ExifReader/assign_terms.html', context) else: print(request.POST.get('ctx')) # prints "None" print(request.POST.get('context')) # prints "None" print(request.POST.get(context)) # Error Obviously I'm not understanding the concepts involved. What's the correct way to pass data from a GET request to POST? (Using Django 2.2.3 and Python 3.8.2) -
architecture for recurring billing system
I'm writing a billing system for my gym. Its a subscription based business, billing the clients every month with no expiration unless it is explicitly set. If it makes any difference, I'm writing it in python/django, but my question is from the architechtural point of view so I'm not sure if that matters. So I'm trying to figure it out the best way to consistently generate the charges every month. There's the Contract table/model object, where every subscription will be stored. There's also the "Billing" table, where each monthly bill will be generated, stored and kept track of its status. Also there will be the ChargingAttempt table (there might be more than one attempt if the first one fails). My question is: Is there a suggested way to generate bills (billing table items) and keep track of which have already been generated? Lets say a client has a plan that started on March 25. Today is May 20, and in 5 days I have to generate the billing for its 3rd cycle. How to generate a billing table row aware of this information? I feel that I'm missing something very simple and obvious there, but cant tell what. Some of … -
AttributeError: 'ReturnList' object has no attribute 'status_code'
when I test this view @action(methods=['GET'], detail=True) def nearby(self, request, pk=None): """get nearby energy resources to the current energy resource in detail""" energy_resource = self.get_object() energy_resources = EnergyResource.objects.annotate( distance=Distance('location', energy_resource.location) ).order_by('distance')[0:3] serializer = self.get_serializer(energy_resources, many=True) return Response(serializer.data) with this test def test_retrieve_nearby_energy_resources(self): """Test getting a list of three nearby energy resources""" test_user2 = get_user_model().objects.create_user( username='test2', password='test2password') r = sample_resource(self.user, 5, 5) sample_resource(test_user2, 4, 5) sample_resource(test_user2, 5, 4) sample_resource(test_user2, 5, 3) r4 = sample_resource(test_user2, 25, 63) url = reverse('energy-resource-nearby', args=[r.id]) response = self.client.get(url) resources_nearby = EnergyResource.objects.exclude(id=r4.id).order_by() resource_not_nearby = EnergyResource.objects.get(id=r4.id) serializer_nearby = EnergyResourceSerializer( resources_nearby, many=True) serializer_not_nearby = EnergyResourceSerializer(resource_not_nearby) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertContains(response.data, serializer_nearby.data) self.assertNotContains(response.data, serializer_not_nearby) it returns ERROR: test_retrieve_nearby_energy_resources (energy_resources.tests.test_views.EnergyResourcePrivateAPITests) Test getting a list of three nearby energy resources ---------------------------------------------------------------------- Traceback (most recent call last): File "/workspace/energy_resources/tests/test_views.py", line 210, in test_retrieve_nearby_energy_resources self.assertContains(response.data, serializer_nearby.data) File "/root/.local/share/virtualenvs/workspace-dqq3IVyd/lib/python3.8/site-packages/django/test/testcases.py", line 445, in assertContains text_repr, real_count, msg_prefix = self._assert_contains( File "/root/.local/share/virtualenvs/workspace-dqq3IVyd/lib/python3.8/site-packages/django/test/testcases.py", line 416, in _assert_contains response.status_code, status_code, AttributeError: 'ReturnList' object has no attribute 'status_code' ---------------------------------------------------------------------- Ran 12 tests in 2.250s it works in broswer and if I commented out assertContain and assertNotContain the test passes so it meants the response has status code attribute, right? what is different about assertContain and assertNotContain? -
Django-Page not found
I'm a real newbie to Django, (following tutorial in openclassroom) I have a django project called "blog", the code in the file "urls.py" of the main DjangoProject is this: DjangoProject\urls.py The code in blog\urls is this: blog\urls.py When I run the server, I get this: Result Help is very much appreciated ! -
SMTPServerDisconnected at /accounts/send_email Connection unexpectedly closed
I am currently experiencing this struggle. I did the following code: EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 EMAIL_HOST_USER = 'xxxxxxxx@gmail.com' EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_PASSWORD') EMAIL_USE_TLS = True As for 'EMAIL_PASSWORD' - I already set the EMAIL_PASSWORD environment variable in the shell that’s running runserver. I kept ending up receiving the SMTP error below: smtplib.SMTPServerDisconnected: Connection unexpectedly closed when I tried to run my Django - sending email using gmail. Am I missing something? Your help would be so much appreciated! -
How to stop autopep8 not installed messages in Code
I'm a new Python programmer using the Mac version of VS Code 1.45.1 to create a Django project. I have the Python and Django extensions installed. Every time I save a Django file, Code pops up this window: Formatter autopep8 is not installed. Install? Source: Python (Extension) [Yes] [Use black] [Use yapf] I keep clicking the "Yes" button to install the autopep8 extension but this message keeps popping up nevertheless. Is there some trick to configuring VS Code so that this extension will be installed permanently so that I stop getting this error? -
What is a "Foreign Key constraint" error when trying to use a form to update a single field in a django user profile?
I'm using allauth to register users on a django 3 site that I am building. I have also created a user profile app to store other bits and pieces of data. The authorisations and user profile display works. I am now trying to give the user the ability to edit each of the user profile fields individually (i.e., I do not want to edit all fields simultaneously). I'd like to use crispy forms for consistency with other forms in the site. My models.py: class UserProfile(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL, primary_key=True, verbose_name='user', related_name='profile', on_delete=models.CASCADE) bio = models.TextField(max_length=500, blank=True) something = models.CharField(max_length=30, blank=True) def __str__(self): return force_str(self.user.email) The form itself is embedded in a template, dashboard.html. The form only shows if the bio field in UserProfile is empty. I have removed the rest of the template for clarity (but it may be that I have missed some tags..?). ... <div class="card p-2"> {% csrf_token %} {% crispy form form.helper %} </div> ... The form is described in forms.py: from django import forms from django.forms import ModelForm from .models import UserProfile from crispy_forms.bootstrap import Field, InlineRadios, TabHolder, Tab from crispy_forms.helper import FormHelper from crispy_forms.layout import Submit, Layout, Div, Field, Fieldset class UpdateBioForm(forms.ModelForm): bio = … -
Server Error (500) after deploy Django app on heroku
After deploy my django site on heroku all pages works fine except one page which is (view page) and that shows server error(500) on it. code in settings DEBUG = False ALLOWED_HOSTS = ['.herokuapp.com', '127.0.0.1'] If anyone knows this error. Kindly let me know -
In FactoryBoy, how do I set a many-to-many field in my factory?
I'm using Django 2.2 and FactoryBoy to attempt to create some factories to produce the following models ... class CoopType(models.Model): name = models.CharField(max_length=200, null=False, unique=True) objects = CoopTypeManager() class Coop(models.Model): objects = CoopManager() name = models.CharField(max_length=250, null=False) types = models.ManyToManyField(CoopType) address = AddressField(on_delete=models.CASCADE) enabled = models.BooleanField(default=True, null=False) phone = PhoneNumberField(null=True) email = models.EmailField(null=True) web_site = models.TextField() Here is my factory for creating the Coop object ... class CoopFactory(factory.DjangoModelFactory): """ Define Coop Factory """ class Meta: model = Coop name = "test model" address = factory.SubFactory(AddressFactory) enabled = True phone = "312-999-1234" email = "test@hello.com" web_site = "http://www.hello.com" @factory.post_generation def types(self, create, extracted, **kwargs): if not create: # Simple build, do nothing. return if extracted: # A list of types were passed in, use them for type in extracted: self.types.add(type) else: type = factory.SubFactory(CoopTypeFactory) self.types.all().set( (type) ) This is my test ... @pytest.mark.django_db def test_coop_create(self): """ Test customer model """ # create customer model instance coop_from_factory = CoopFactory() self.assertIsNotNone(coop_from_factory) coop = Coop.objects.create(name='test', address=coop_from_factory.address) self.assertIsNotNone(coop) However, it doesn't seem to like this line self.types.all().set( (type) ) from the factory, because the test dies with the below error. What is the proper way to get my factory to work with a many-to-many field? … -
How to chek a path that contains parameters via request.path?
In my questions app, the url_patterns in models.py is : urlpatterns = [ path('<int:question_id>/' , views.question , name='question'), path('new/' , views.new_question, name='newquestion'), path('edit/<int:question_id>/', views.edit , name='edit'), ] In my templates whenever I want to for example check if the newquestion url is loaded, I try this: {% if 'questions/new' in request.path %} some code {% endif %} How to check if the question url is loaded when it contains an integer parameter - the question_id - -
Cannot open another HTML file from Django
I was trying to call one html file from another via Django. I actually have no errors inside my project(It works). But when I am trying to call the second html file the page refreshes only. Here is my code, thanks:D. My projects name is information and the name of my app is basic. basic.views.py: from django.shortcuts import render # Create your views here. def index(request): return render(request,'basic/index.html') def customer(request): return render(request,'basic/customer.html') basic.urls.py: from django.urls import path from basic import views app_name='basic' urlpatterns=[ path('',views.index,name='index'), path('',views.customer,name='customer'), ] information.urls.py: from django.contrib import admin from django.urls import path,include from basic import views urlpatterns = [ path('',views.index,name="index"), path('admin/', admin.site.urls), path('',include('basic.urls')) ] -
127.0.0.1 refused to connect after django manage.py runserver
I'm new to python and django. Yesterday I did the "python manage.py runserver" for the first time(just after django-admin startproject ..) and it showed starting development server at http://127.0.0.1:8000/. But in chrome it said "this site cant be reached". After searching the error I realized I had to add '127.0.0.1' in the list of ALLOWED_HOST(which was an empty list at the beginning) in settings.py. This resolved the error and django congratulations page showed up. But today again the same "this site cant be reached, 127.0.0.1 refused to connect" error. Can someone help me out with this? -
How to write a Celery group or chain using transaction.on_commit
I am using django 3.0.2, python 3.6.6, celery 4.3.0, and redis server 4.0.9. I want to create some chains and groups of tasks that run after the model has been saved (transaction.on_commit). I can make an individual task work this way, but I can't seem to devine the correct incantation to make a group or chain use transaction.on_commit. Sidebar: I extended the celery Task class to "hide" the lamba stuff when using transaction.on_commit because I always had to look up the correct format - see https://browniebroke.com/making-celery-work-nicely-with-django-transactions/ for the details. In my code, I use task.delay_on_commit to replace the transaction.on_commit and lambda. Back to the main story. I tried this code, and it failed saying the the object query in my tasks did not exist. jobs = group(tasks.clean_document_image.delay_on_commit(self.document_id, key, values[key]) for key in values).apply_async() clean_document_image takes an uploaded image (the document_id object's FileField) and creates several copies of the image in different sizes (the key in the values dictionary is the width of the copy, and the value in the values dictionary is just the string name of the size - e.g., thumb, xsmall, xxxlarge, etc.). Notice that I tried to delay each of the elements of the group until the … -
Constant python/django errors
Does anyone know what I should do? I receive this error everytime I interact with my localhost. It does not crash, my terminal just blows up with these exceptions. Does anyone know how I should proceed with this issue? I know this is alot of errors but I am starting to learn more about Django so your help would be greatly appreciated. Thank you! ---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 50979) ---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 50974) ---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 50978) ---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 50980) ---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 50981) Traceback (most recent call last): Traceback (most recent call last): Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 650, in process_request_thread self.finish_request(request, client_address) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 360, in finish_request self.RequestHandlerClass(request, client_address, self) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 720, in __init__ self.handle() File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 174, in handle self.handle_one_request() File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 182, in handle_one_request self.raw_requestline = self.rfile.readline(65537) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socket.py", line 669, in readinto return self._sock.recv_into(b) ConnectionResetError: [Errno 54] Connection reset by peer ---------------------------------------- File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 650, in process_request_thread self.finish_request(request, client_address) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 650, in process_request_thread self.finish_request(request, …