Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
DRF nested routers: Improperly configured URL
I am trying to build an app using the DRF's quickstart guide. The app has the following setup /school/ /school/<pk> /school/<pk>/courses/ /school/<pk>/courses/<pk> /school/<pk>/courses/<pk>/members/ When I follow the quickstart I get the following error ImproperlyConfigured at /api/v1/school/1/courses/1/members/ Could not resolve URL for hyperlinked relationship using view name "courses-detail". You may have failed to include the related model in your API, or incorrectly configured the `lookup_field` attribute on this field. when vising /school/<pk>/courses/<pk>/members/ I don't really understand the error message I am getting as I have the view name "courses-detail" readily available. Could anybody help me clear out what I have done wrong? This is the code I have in the example application. views.py # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.shortcuts import render, get_object_or_404 from rest_framework import viewsets, permissions from rest_framework.response import Response from .serializers import SchoolSerializer, SchoolActivitySerializer, SchoolCourseSerializer, CourseSerializer, ActivitySerializer, SchoolCourseMemberSerializer, MemberSerializer from .models import School, Course, Activity, Member # Create your views here. class SchoolViewset(viewsets.ModelViewSet): serializer_class = SchoolSerializer queryset = School.objects.all() class CourseViewset(viewsets.ModelViewSet): serializer_class = CourseSerializer queryset = Course.objects.all() def get_school(self, school_pk): school = get_object_or_404(School.objects.all(), pk=school_pk) return school def list(self, request, *args, **kwargs): queryset = Course.objects.all() serializer = CourseSerializer(queryset, many=True) return Response(serializer.data) class MemberViewset(viewsets.ModelViewSet): serializer_class = … -
Django - How to parse Json data that is inside of a body?
I am a beginner in Django. I want to parse Json data that is inside the body in URL(example: 0.0.0.0:8080/rooms). How can i get that data and parse it? -
how get a variable from url to form's method - save?
I have urlpattern with id ... url(r'^3/(?P<id>[-\w]+)', Biochemical_analysis_of_blood.as_view(),\ name='biochemical_analysis_view'), ... views.py class Biochemical_analysis_of_blood(CreateView): model = BiochemicalAnalysisOfBlood form_class = BiochemicalAnalysisOfBloodForm template_name = "biochemical_analysis_of_blood.html" success_url = reverse_lazy("patients") def get_context_data(self, **kwargs): context = super(Biochemical_analysis_of_blood, self).get_context_data(**kwargs) context["patient"] = Patient.objects.get(id=self.kwargs['id']) context["caption"] = 'Біохімічний аналіз крові' context["new"] = True return context forms.py class SaveForms(): def save(self, commit=True): analysis = Analyzes() sid = transaction.savepoint() analysis.name = self.data["name"] analysis.patient_id = Patient.objects.get(id=1) analysis.who_send = self.data["who_send"] analysis.who_is_doctor = self.data["who_is_doctor"] analysis.lab_user_id = Doctor.objects.get(id=self.data["lab_user_id"]) analysis.additional_lab_user = self.data["lab_user_add"] analysis.date = self.data["date"] analysis.type = 3 analysis.date_analysis = self.data["date_analysis"] analysis.save() # Your analysis is created, attach it to the form instance object self.instance.analysis_id = analysis.id return super().save(commit) How I can get a variable "id" from url to form's method - save? class SaveForms will be inherethed by other forms.models classes because they all must have same save method. ... analysis.patient_id = Patient.objects.get(id=1) ... Instead "1" I must use "id" from url...Who can help me, please? class BiochemicalAnalysisOfBloodForm(SaveForms, forms.ModelForm): ... -
Django Admin TabularInline - Getting Foreign Key through a OneToOne Relationship
As shown below, I want to display one model (Attendance) in the admin change view of another (Event) as a TabularInline. However, Attendance doesn't have a direct ForeignKey pointing to Event. Rather, it has a OneToOne relationship with Registration, which in turn points to Event. Any simple ways of achieving this? As you can see from the code, I tried to access the Event using a method, and pass it into the TabularInline class as fk_name, but it threw an error saying "'myapp.Attendance' has no field named 'get_fk'". myapp/models.py from django.db import models class Event(models.Model): ... class Registration(models.Model): event = models.ForeignKey(Event, on_delete=models.CASCADE) ... class Attendance(models.Model): registration = models.OneToOneField(Registration, primary_key=True, one_delete=models.CASCADE) ... def get_fk(self): return self.registration.event myapp/admin.py from django.contrib import admin class AttendanceInline(admin.TabularInline): model = Attendance fk_name = 'get_fk' class EventAdmin(admin.ModelAdmin): inlines = [AttendanceInline] Appreciate it if anyone could help! -
Does a Django app and an Angular component serve the same purpose?
I have a good experience with Angular and I'm trying to learn Django. Are an app and a component similar? -
How do I verify webhook Twitter Bot for Direct Messaging?I am using python
So I have been trying to build a twitter DM Bot and i want to reply users by reading their DMs.I read their documentary and I am unable to send requests on the specified url in the webhook documentary guide url1 = 'https://api.twitter.com/1.1/account_activity/webhooks.json' data = json.dumps({url:'https://55a3a9ad.ngrok.io'}) request.post(url1,data=data) -
How to use Docker with Django project and virtualenv and deploy on Heroku
I would like to use Docker with my existing Django project in virtualenv and MySQL database. It seems to my that my solution is not optimal (BTW it is not working). My app is not finished, but I wonder if it is possible to deploy it on Heroku and working with it without publishing? I will be grateful if you could show me the best solution. To wit this is my docker-compose.yml: web: build: . command: python manage.py runserver 0.0.0.0:8000 volumes: - .:/code ports: - "8000:8000" db: image: mysql environment: - MYSQL_ALLOW_EMPTY_PASSWORD=yes - MYSQL_USER=root - MYSQL_DATABASE=pri Dockerfile: FROM python:3 ENV PYTHONUNBUFFERED 1 RUN mkdir /code WORKDIR /code ADD requirements.txt /code/ RUN pip install -r requirements.txt ADD . /code/ settings.py: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'pri', 'USER': 'root', 'HOST': 'db', } } Structure of my files looks in this way: My DockerContainerDirectory: - docker-compose.yml - Dockerfile - requirements.txt - ProjectDirectory In ProjectDirectory I have virtualenv and Project: - bin - include - lib - pip-selfcheck.json - Project In Project I have git repository, back-end and front-end written in Angular2: - backendFolder - frontendFolder In backendFolder: -backendProject In -backendProject: - my project with `manage.py` etc. -
Get nested object in Django REST.. How to add it to "top" field?
Been at this a while and cannot figure it out. I am using VersatileImageFieldSerializer and it puts the thumbnail and photo url within the objects photo field. Eg. instead of a url like 'photo', it is now 'photo.full_size' and 'photo.thumbnail'. Because I use depth = 1 on the User model to reach all my properties on my client-side (Angular), I cannot reach them. Is there a way to "return" these fields to the top? Sorry if this question sounds difficult, I am explaining the best I can. Thank you. -
Class reference inside class scope in python
Some Context I have the following django/python snippet: from rest_framework import serializers from .models import Profile, Task class Serializable(): types = {} def __init__(self, objectid): self.object = self.types[objectid][0] self.serializer = self.types[objectid][1] def serialized(self): instances = self.object.objects.all() serialized = self.serializer(instances, many=True) return serialized class ProfileSerializer(serializers.ModelSerializer): class Meta: oid = 'profile' model = Profile fields = ['login', 'status'] Serializable.types[oid] = [model, <class-reference>] class TaskSerializer(serializers.ModelSerializer): class Meta: oid = 'task' model = Task fields = ['description', 'date', 'owner'] Serializable.types[oid] = [model, <class-reference>] I am using Django with the rest_framework library installed. One of the interesting features I am using is ModelSerializers (ModelSerializers Documentation), which save quite a lot of code repetition. I want Serializable.types variable to be populated on runtime (when all the serializer classes are declared). The whole point of this is that I will not have to update my views whens a new type of model is included. For example, I would print the json representation of my model instances like this: class QueryObject(APIView): permission_classes = (AllowAny,) def get(self, request, *args, **kwargs): oid = request.GET['oid'] serializable= Serializable(oid) json = serializable.serialized return JsonResponse(json) The Problem The major problem is in the last line of each Serializer class. Serializable.types[oid] = [model, <class-reference>] I've … -
Testing Django w/ DRF: issues defining a base test class for multiple test cases to inherit
I'm working on a Django app that exposes an API with the help of Django REST Framework (DRF). I've gotten to the point where I need to create a testing framework and have been poring over both the DRF and Django testing docs. I've defined a BaseTestCase class that sets up basic required data needed for all other test cases, as well as a ModelTestCase class that inherits from BaseTestCase, in order to make use of the setup performed. Here's how those look right now: BaseTestCase class BaseTestCase(APITestCase): ''' This class does basic data setup required to test API endpoints Creates 1+ users, sets the client to use that user for auth ''' @classmethod def create_data(cls): ''' Create the users needed by automated tests ''' # creates some data used by child test cases @classmethod def setUpClass(cls): client = APIClient() cls.client = client # call the method to create necessary base data cls.create_data() # get a user and set the client to use their auth user = get_user_model().objects.get(email='auto-test@test.com') client.force_authenticate(user=user) # cls.client = client super(BaseTestCase, cls).setUpClass() def test_base_data(self): ''' This test ensures base data has been created ''' # tests basic data to ensure it's created properly def test_get_users(self): ''' This … -
Can I have multiple domain names point to different subdirectories on the same server
I have two domain names www.blog.com and www.project.com Currently, www.blog.com/project points to my project page. I have nginx configured to redirect any requests to /project to my Django project. I have just purchased www.project.com, and I would like it to display the same content as www.blog.com/project without it's URL changing in the browser. I'm not sure if there is a way to do this with DNS (a redirect won't preserve the URL), or a way to determine if a request came from www.blog.com or www.project.com at the server level. In short: blog.com stays pointing to root blog.com/project needs keep being forwarded to Django project.com now needs to appear in the browser bar and perform like 2. -
How do I run my Django website on 1and1 Web Hosting?
Ok I have uploaded all of my files through FileZilla and have the domain pointed to the right folder where manage.py resides. I have also installed Django on the server itself. I can run python manage.py runserver successfully by using putty to get into the server but the domain does not pick up the running instance of the website. I don't even know where to begin here. It's a Linux server. Please help. -
-nginx, uwsgi, 502 Bad gateway on domain
I was looking all over the internet for solutions, but none helped. I want to deploy a django project at my server pointed to vps.florisdeboer.com. I've read some tutorials and did exactly what they told me, but the 502 error keep showing up. I've got all important files, if you miss something, please comment while I can post it as an edit. OK, let's go: The projectname is webshop. Nothing special, just a webshop build in django. I use db.sqlite3 as my database. /etc/uwsgi/sites [uwsgi] project = webshop uid = floris base = /home/%(uid) chdir = %(base)/%(project) home = %(base)/BIT/ module = %(project).wsgi:application master = true processes = 5 socket = /run/uwsgi/%(project).sock chown-socket = %(uid):www-data chmod-socket = 660 vacuum = true plugins=python27 /etc/nginx/sites-enabled server { listen 80; server_name florisdeboer.com vps.florisdeboer.com; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /home/floris/webshop; } location / { include uwsgi_params; uwsgi_pass unix:/run/uwsgi/website.sock; } } And the sudo systemctl status uwsgi ● uwsgi.service - uWSGI Emperor service Loaded: loaded (/etc/systemd/system/uwsgi.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2017-06-17 22:13:00 CEST; 17h ago Main PID: 24782 (uwsgi) Status: "The Emperor is governing 1 vassals" CGroup: /system.slice/uwsgi.service ├─24782 /usr/local/bin/uwsgi --emperor /etc/uwsgi/sites … -
Formset has not changed
Django 1.11.2 I'm studying documentation. This place: https://docs.djangoproject.com/en/1.11/topics/forms/formsets/#django.forms.formsets.BaseFormSet.total_error_count We can read: "We can also check if form data differs from the initial data (i.e. the form was sent without any data)". I organized a special breakpoint in the code below. Well, that is true. The form has not changed. But I decided that this example is not very picturesque. Why should we check whether something has changed if we did not change anything. Well, I organized initial_data. And tried formset_1.has_changed(). Result: False. In the debugger at Breakpoint: strange. formset_1.initial = <class 'list'>: [{'form-TOTAL_FORMS': '1', 'form-INITIAL_FORMS': '0', 'form-MAX_NUM_FORMS': '', 'form-0-title': '', 'form-0-pub_date': '2017-06-17'}] formset_1.data = {'form-TOTAL_FORMS': '1', 'form-INITIAL_FORMS': '0', 'form-MAX_NUM_FORMS': '', 'form-0-title': '', 'form-0-pub_date': ''} But why should formset_1.has_changed() be false? Data really differs from initial data. ArticleFormSet = formset_factory(ArticleForm) data = { 'form-TOTAL_FORMS': '1', 'form-INITIAL_FORMS': '0', 'form-MAX_NUM_FORMS': '', 'form-0-title': '', 'form-0-pub_date': '', } formset = ArticleFormSet(data) formset.has_changed() pass # Breakpoint: We can also check if form data differs from the initial data (i.e. the form was sent without any data). initial_data = [{ 'form-TOTAL_FORMS': '1', 'form-INITIAL_FORMS': '0', 'form-MAX_NUM_FORMS': '', 'form-0-title': '', 'form-0-pub_date': '2017-06-17', },] formset_1 = ArticleFormSet(data=data, initial=initial_data) formset_1.has_changed() pass # Breakpoint: strange. -
make migrateion in models - django
i want to add some field to my perevios field in my database(sqlite) : class Image(models.Model): name = models.CharField (max_length=100) link = models.CharField (max_length=100) #add this field(my new field) : owner = models.CharField (max_length=100) but when i run this code at cmd : python .\manage.py makemigrations i will recive a error : WARNINGS: ?: (1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 a nd the TEMPLATES dictionary takes precedence. You must put the values of the fol lowing settings into your default TEMPLATES dict: TEMPLATE_DEBUG. You are trying to add a non-nullable field 'owner' to image without a default; w e can't do that (the database needs something to populate existing rows). Please select a fix: 1) Provide a one-off default now (will be set on all existing rows with a null value for this column) 2) Quit, and let me add a default in models.py Select an option: i dont know where is mistake. note : when i want to remove field it work!!!! -
How do you change the displayed model name in the admin site of Django? [duplicate]
This question already has an answer here: Is it possible to change the model name in the django admin site? 1 answer How do you change the displayed model name in the admin site of Django? Currently admin site just add an 's' after the model name. -
Django constance - on save method
Is there any way to call django command after changing constance value? I need to call: python manage.py installtasks for my kronos cron jobs. I don't have any idea how can I set this. In constance docs I found: from constance.signals import config_updated @receiver(config_updated) def constance_updated(sender, key, old_value, new_value, **kwargs): print(sender, key, old_value, new_value) but I don't know what is receiver (I get "NameError: name 'receiver' is not defined") and where should I put this code. Any help? -
How to check blank input field validation using python and Django
I need some help. I need to validate fields if they are blank at the time of form submit. I am explaining my code below. bmr.html: <form method="post" action="{% url 'some' %}"> {% csrf_token %} <label>location name: </label> <input name="lname" maxlength="250"> <br> <label>Room name: </label> <input name="rname" maxlength="250"> <br> <label>No of Seats: </label> <input type="number" name="seat" maxlength="10"> <br> <label>Projector Screen</label> <select name="projector"> <option value="Yes">Yes</option> <option value="No">No</option> </select> <br> <label>Video conference</label> <select name="video"> <option value="Yes">Yes</option> <option value="No">No</option> </select> <br> <input type="submit" value="Submit"> </form> the python side code is given below. def some(request): if request.method == 'POST': serch=request.POST.get('searchby') location_name = request.POST.get('lname') rname = request.POST.get('rname') seat = request.POST.get('seat') projector = request.POST.get('projector') video = request.POST.get('video') num=str(random.randint(100000000000,999999999999)) location_name = location_name[0:255] rname = rname[0:255] seat = seat[0:10] doc = m.parse("roomlist.xml") root=doc.getElementsByTagName("roomlist") valeurs = doc.getElementsByTagName("roomlist")[0] element = doc.createElement("location") element.setAttribute("name" , location_name) el1 = element.appendChild(doc.createElement("room")) el1.setAttribute("id", num) el2=el1.appendChild(doc.createElement("roomname")) el2.appendChild(doc.createTextNode(rname)) el3=el1.appendChild(doc.createElement("noseats")) el3.appendChild(doc.createTextNode(seat)) el4=el1.appendChild(doc.createElement("projectorscreen")) el4.appendChild(doc.createTextNode(projector)) el5=el1.appendChild(doc.createElement("videoconf")) el5.appendChild(doc.createTextNode(video)) valeurs.appendChild(element) doc.writexml(open("roomlist.xml","w")) return render(request, 'booking/bmr.html', {}) Here I need if ant field is blank it will show user the validation message and the form will not submit.Please help me. -
Downloaded Python 3.6 but terminal is still saying I'm using python 2.7.12
I have looked for Python 2.7.12 in my apps and docs but I can't find it... I'm using a macbook pro. I can see Python 3.6 in my applications so I don't know why the terminal isn't referring to this one. I want to get started learning django but I don't think it will be possible if I don't use Python 3.5 or later. is there a way to tell the terminal to use 3.6 instead? Thanks -
How to get Sha256 checksum in browser and send it along with file upload to the server in a POST request
I need to make a python django page where it's possible to upload a file (under 10KB) that would show the Sha256 checksum of it and show how many times this file was uploaded before. There's also a subgoal of making the browser itself calc Sha256. I already have an idea on how to do it, but I lack the knowledge on details and I'd appreciate if you could point me in the right direction. I want to create a simple webpage with a form for a file upload. I'd like to make JS intercept the file and calc Sha256 in browser and send it as an additional field in a POST request along with the file itself to a certain URL. Is it even possible to do this thing? Then I'll calculate Sha256 with Python on the server side and compare Sha256's received and if they match I'll increment a field in DB matching this Sha256 by 1. I am also planning on using AJAX so I don't need to reload a page after I upload the file to get the Sha256 value and the number of files uploaded before. Please if you have suggestions on how it can … -
"This field is required" when sending POST request to Django Rest Fremework API
I'm trying to create a new Category, which simply has name field to be filled up, but it insists on showing the error saying it's required. models.py: class Category(models.Model): name = models.CharField(max_length=32, unique=True) created_at = models.DateTimeField(default=timezone.now) updated_at = models.DateTimeField(default=timezone.now) def __str__(self): return self.name serializers.py class CategorySerializer(serializers.Serializer): id = serializers.IntegerField(required=False) name = serializers.CharField(max_length=32) def create(self, validated_data): return Category.objects.create(**validated_data) def update(self, instance, validated_data): pass views.py class CategoryList(APIView): def get(self, request): """ Gets all the existing categories :param request: :return: Category """ categories = Category.objects.all().filter().order_by("name") serializer = CategorySerializer(categories, many=True) return Response(serializer.data) def post(self, request): """ Create one new category :param request: :return: Category """ serializer = CategorySerializer(data=request.data) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=HTTP_201_CREATED) return Response(serializer.errors, status=HTTP_400_BAD_REQUEST) Priting request.data shows me, for example: {'data': {'name': 'Withdrawal'}}. It shows the data are being sent and received but I don't understand why this errors shows up. I checked up other questions but none helped me. -
localhost server in compiled Python program
I was looking to develop a tool for Windows with a GUI, however, reading around I am now looking to see if/how it is possible to have my compiled python code make it possible for users to have access a localhost server to interact with the tool (much like Jupyter notebook/labs). I would assume this is fairly common and that something already exists. Is it something that could be done with -for example- a Django development project or is there a standard package that can be imported? Ideally, I want an executable file that users can run and their browser opens up at the localhost port required. -
All fields give this field is required error
When I submit this form & all fields are correctly populated, the form.is _valid() returns false & all the fields give : this field is required error, even the CharField!!! can anybody see what's wrong? this is my form: class TemplateConfiguredForm(forms.Form): """This form represents the TemplateConfigured Form""" template = forms.ChoiceField(widget=forms.Select(attrs={'id':'TemplateChoice'})) logo = forms.ImageField( widget = forms.FileInput(attrs={'id': 'inputLogo'})) image = forms.ImageField(widget = forms.FileInput(attrs={'id': 'inputImage'})) message = forms.CharField(widget = forms.Textarea(attrs={'id': 'inputText', 'rows':5, 'cols':25})) def __init__(self, custom_choices=None, *args, **kwargs): super(TemplateConfiguredForm, self).__init__(*args, **kwargs) r = requests.get('http://127.0.0.1:8000/sendMails/api/templates/?format=json') json = r.json() custom_choices=( ( template['url'], template['name']) for template in json) if custom_choices: self.fields['template'].choices = custom_choices this my template: <form id="template_form" method="post" role="form" enctype="multipart/form-data" action="{% url 'create_templates' %}" > {% csrf_token %} {{ form.as_p }} {% buttons %} <input type="submit" value="Save Template"/> {% endbuttons %} </form> this is my view: def create_templates(request): if request.method == 'POST': form = TemplateConfiguredForm(request.POST, request.FILES) if form.is_valid(): template_configured = TemplateConfigured() template_configured.owner = request.user template_configured.logo = form.cleaned_data["logo"] template_configured.image = form.cleaned_data["image"] template_configured.message = form.cleaned_data["message"] template = form.cleaned_data['template'] template = dict(form.fields['template'].choices)[template] template_configured.template = Template.objects.get(name = template) template_configured.save() saved = True else: print form.errors else: form = TemplateConfiguredForm() return render(request, 'sendMails/createTemplates.html', locals()) -
Django-datatable-view X-editable internal server error
I have been struggling with this one for a couple of days now. I would like to use django-datatable-view's xeditable columns integration. My code loads the datatable correctly (see here) but whenever I specify the columns to make_xeditable, I get an 500 Internal Server error. I have looked at the few pages (Can't post links due to not enough rep...) that discuss django-datatable-view but none of them discuss the x-editable option. Using the snippets from the live demo online (here) (version 0.7) just doesn't do anything. The table loads but the column isn't editable. class PriceListDataTableView(XEditableDatatableView): model = PriceList datatable_options = { 'columns': [ 'id', 'date', 'product', 'unit', ("Price", 'price', helpers.make_xeditable), ] } I got the latest version (0.9) running on my localhost, and their example works! But I can't get it to work in my own app. Both setups run django 1.8 Here is my model: class PriceList(models.Model): # Fields date = models.DateField(verbose_name="Price list date") product = models.CharField(verbose_name="Product name", max_length=100) unit = models.CharField(verbose_name="Unit", max_length=6) price = models.DecimalField(verbose_name="Price", decimal_places=2, max_digits=10) Here is my template: {% extends "agrichem/base.html" %} {% block content %} <script> $(document).ready(function() { <!-- Initialization for x-editable tables --> $.fn.editable.defaults.mode = 'inline'; $(function(){ var xeditable_options = {}; datatableview.initialize($('.datatable'), … -
I got an error when I uploaded a image from Swift app to a server
I got an error when I uploaded a image from Swift app to a Django server, but I cannot understand the error's meaning. Traceback is objc[31747]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x11aa7d998) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x119968880). One of the two will be used. Which one is undefined. 2017-06-16 23:11:52.837756 Kenshin_Swift[31747:1350088] [Generic] Creating an image format with an unknown type is an error 2017-06-16 23:11:54.274757 Kenshin_Swift[31747:1350153] [] nw_socket_get_input_frames recvmsg(fd 13, 1024 bytes): [54] Connection reset by peer 2017-06-16 23:11:54.276896 Kenshin_Swift[31747:1350153] [] nw_endpoint_flow_prepare_output_frames [1 127.0.0.1:8000 ready socket-flow (satisfied)] Failed to use 1 frames, marking as failed 2017-06-16 23:11:54.277301 Kenshin_Swift[31747:1350153] [] nw_socket_write_close shutdown(13, SHUT_WR): [57] Socket is not connected 2017-06-16 23:11:54.277684 Kenshin_Swift[31747:1350153] [] nw_endpoint_flow_service_writes [1 127.0.0.1:8000 ready socket-flow (satisfied)] Write request has 0 frame count, 0 byte count 2017-06-16 23:11:54.278467 Kenshin_Swift[31747:1350154] [] __tcp_connection_write_eof_block_invoke Write close callback received error: [89] Operation canceled error=Optional(Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x60800025cda0 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=http://127.0.0.1:8000/accounts/upload_save/, NSErrorFailingURLKey=http://127.0.0.1:8000/accounts/upload_save/, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out.}) I wrote right url in Swift which is used to upload image, and the url can be accessed by server's being run python manage.py runserver 0.0.0.0:8000,and I run my server for being able to access from other devises which …