Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Dev Ops: Amazon Web Services - Taking too long to respond
I've just finished setting up my site on a free Amazon Web Services EC2 Ubuntu server. I'm not very knowledgeable in Dev Ops, and I'm not 100% clear on what Nginx or gunicorn even is, but I'm following a tutorial to launch a Django project. While doing things the same exact way, having no errors, I have noticed that sometimes I will go to my site and get 'refused to connect' or 'taking too long to respond.' One of my previous projects had no issue, one of them never loaded the page, and the last one I did gave me this problem which was cured by rebooting the server. I've rebooted the server several times as well as deactivated and reactivated the venv (as a classmate suggested) but it isn't working. I noticed that last night my terminal just kept taking forever to load and the Amazon web services site was just being slow as well. Is this just Amazon's fault? Is there anything I can do? -
Django-storages adds suffix old files but doesn't upload new ones
I am using Django-storages=1.6.5 plugin and facing this strange problem while running collectstatic. The previous files with same name on my s3 bucket are renamed by appending a random suffix, which is expected behaviour as I have AWS_S3_FILE_OVERWRITE set to False. But what is strange is that its not uploading the new files to s3 bucket. For example, if I had a file named base.css on in the bucket, after running collectstatic, it would be renamed for base_U4fg4G.css and no new file with name base.css is uploaded to the bucket. This is my entire configuration for Django-storages STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage' AWS_ACCESS_KEY_ID = os.environ['AWS_ACCESS_KEY_ID'] AWS_SECRET_ACCESS_KEY = os.environ['AWS_SECRET_ACCESS_KEY'] AWS_STORAGE_BUCKET_NAME = os.environ['AWS_STORAGE_BUCKET_NAME'] AWS_DEFAULT_ACL = 'private' AWS_S3_SECURE_URLS = values.BooleanValue(False, environ_prefix='', environ_name='AWS_S3_SECURE_URLS') AWS_AUTO_CREATE_BUCKET = False AWS_PRELOAD_METADATA = True AWS_S3_FILE_OVERWRITE = False AWS_EXPIRY = 60 * 60 * 24 * 7 AWS_HEADERS = { u'Cache-Control': u'max-age=%d, s-maxage=%d, must-revalidate' % ( AWS_EXPIRY, AWS_EXPIRY ) } Can anyone figure out whats happening here? -
Django form adding element before a field?
Here is what my current form looks like class sForm(forms.ModelForm): """Form to create new instance. """ class Meta: model = sModel fields = ('title','twitter_username') def __init__(self, *args, **kwargs): super(sForm, self).__init__(*args, **kwargs) self.fields['title'].widget.attrs['placeholder'] = 'Title' self.fields['twitter_username'].widget.attrs['placeholder'] = '@twitter' The form works absolutely fine. Now before the twitter element i want to add "@" symbol. Similar to this pen. I am unsure how to do that ? thanks for helping me out -
Python not loading CSS
Ok I am new to Python, I am using Django here. I cannot get my Python to see the CSS file and use it. I have tried hardcoding the path, server restarts, nothing works. I can get it to read a Bootstrap CDN however, I am not sure what is wrong. My File structure is like so: -migrations -static --music ---images ---style.css (the file that i'm trying to get) -templates --music ---index.html (where my link attribute is) I am trying to load the static CSS file in index.html like so: {% load staticfiles %} <link rel="stylesheet" type="text/css" href= "{% static 'music/style.css' %}"/> Here is the CSS: body { background-color: red; } Thanks in advance! -
Talking with a DJANGO server from ANDROID-STUDIO client
i'm developing an app that the client is android studio, and the server is a rest-server built at Django. The client communicates with Retrofit. I have this API-client: public class APIClient { public static final String BASE_URL = "http://127.0.0.1:8000/api/"; // public static final String BASE_URL = "https://api.github.com/"; private static Retrofit retrofit = null; public static Retrofit getClient(){ if (retrofit==null){ retrofit = new Retrofit.Builder().baseUrl(BASE_URL) .addConverterFactory(GsonConverterFactory.create()) .build(); } Log.i("DEBUG APIClient","CREATED CLIENT"); return retrofit; } } When I speak with "https://api.github.com/" (The commented line) it works great. But when I speak with my server, at "http://127.0.0.1:8000/api/", the call is not getting response. This is my server's root: enter code here HTTP 200 OK Allow: GET, HEAD, OPTIONS Content-Type: application/json Vary: Accept { "users": "http://127.0.0.1:8000/api/users/", "login": "http://127.0.0.1:8000/api/login/", "routes": "http://127.0.0.1:8000/api/routes/", "runs": "http://127.0.0.1:8000/api/runs/" } And when I send get-request for example localhost/api/users/Sammy/, Using the github-APi I get all of the data, but with my APi I don't get response. Thanks alot :) -
Debug datetime formatting in django
I've inherited a django project, and there's a model with a datetime field (yes, the model is called "Test", as in "lab test") class Test(models.Model): datetime = models.DateTimeField() This field is formatted as May 16, 2017, 9:55 a.m. in the template, and I need to change that, but have no idea where this formatting is coming from, and hence how to change it. Here's the template code, the able is built in a for loop, nothing fancy, and then modified with datatables.net JavaScript (which I can disable and has no effect, so formatting is applied before that): {% load static i18n tz epoch_tag postman_tags %} ... {% for test in tests %} ... <td>{{ test.datetime|default_if_none:"" }}</td> ... {% endfor %} ... The view is a standard ListView with a normal queryset, nothing odd there. Here's what I have in the settings, after un-commenting various lines: LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' # Doesn't work DATE_FORMAT = "Y-m-d" SHORT_DATETIME_FORMAT = "Y-m-d" #USE_I18N = True #USE_L10N = True #USE_TZ = True Here are the context processors, with the ones I've tried commenting out: 'django.template.context_processors.request', #'django.template.context_processors.i18n', 'apps.postman.context_processors.inbox', 'apps.biomarker.context_processors.base_template_for_user_type', 'apps.menus.context_processors.menu_elements', #'django.template.context_processors.tz', 'django_settings_export.settings_export', 'apps.biomarker.context_processors.custom_pages', 'apps.hm_multitenancy.context_processors.add_practice_context' The third party apps, with the ones I've tried commenting … -
django deployment : ASGI app does not loading static files
WhiteNoise introduces itself : whitenoise works with any-WSGI compatible app. Then, what package should I use for ASGI app?? Let's suppose url /chatting/ is rendered by index.html. For the first time we access /chatting/. When I click html li tag, this code is executed. // Room join/leave $("li.room-link").click(function () { roomId = $(this).attr("data-room-id"); if (inRoom(roomId)) { // Leave room $(this).removeClass("joined"); webSocketBridge.send({ "command": "leave", "room": roomId }); } else { // Join room $(this).addClass("joined"); webSocketBridge.send({ "command": "join", "room": roomId }); } }); joined class added successfully!! However, after that(click event) Nothing is happen. when I see log, it seems that websocket connection is still working. Currently In my project, ASGI app failed to load jQuery static file. What should I do for ASGI app to load jquery static file. I deployed my django project on Heroku. So I'd like to fix it in production environment.(in development environment it is working fine.) below is my heroku Procfile setting. web: gunicorn multichat.wsgi --log-file - web2: daphne multichat.asgi:channel_layer --port $PORT --bind 0.0.0.0 -v2 worker: python manage.py runworker -v2 and it is index.html full code. {% extends "base.html" %} {% block title %}MultiChat Example{% endblock %} {% block header_text %}MultiChat Example{% endblock %} {% block … -
return count of rows and sum from the same model
Sorry for the unclear title...I donno how to put it right. Basically, I have the following model: class Items(models.Model): total=models.IntegerField() Sample Data now is simply: 1 10 2 15 3 90 6 10 9 20 I have totally 5 items with a total of 145. I tried the following but it failed cos it is grouping the id column which returns me a dictionary in the following strucutre: {"total_items":1,"items_worth":10, "total_items":2,"items_worth":15} where as what I want is: {"total_items":5, "total_worth":145} in SQL, it was ok: SELECT COUNT(id) as total_items,SUM(total) as total_worth Whereas DJANGO adds, SELECT COUNT(id) as total_items,SUM(total) as total_worth FROM model GROUP BY id This is my current Django Query: data=Items.Objects.all().annotate(total_items=Count('id'),total_worth=Sum('total')).values('total_items','total_worth') Something tells me this is easier but.. -
Django admin site column headers sort by values not alphabetical?
How do you make Django admin site to strictly sort by values alphabetically when column headers are clicked? MyAdmin(admin.ModelAdmin): list_display = ('column1', 'column2') Here column2 header when clicked should sort the change list alphabetically but is not? column2 b a c or column2 c a b is the output. -
AWS ECS using docker and ngnix, how to get my nginx config into the container?
I'm trying to setup a ECS cluster in AWS using Nginx, unicorn and Django. I have converted my docker-compose.yml into a ECS task, but am wondering how I get my nginx config into the container? this is my task in json I have created some mount points for files but am unsure how to get the config there. when I run docker from my local servers the nginx config file is local to the compose file, obviously in aws it is not? how do I get the nginx config into the contain through ecs? { "containerDefinitions": [ { "volumesFrom": null, "memory": 300, "extraHosts": null, "dnsServers": null, "disableNetworking": null, "dnsSearchDomains": null, "portMappings": [ { "containerPort": 8000, "protocol": "tcp" } ], "hostname": null, "essential": true, "entryPoint": null, "mountPoints": [ { "containerPath": "/static", "sourceVolume": "_Static", "readOnly": null } ], "name": "it-app", "ulimits": null, "dockerSecurityOptions": null, "environment": null, "links": null, "workingDirectory": "/itapp", "readonlyRootFilesystem": null, "image": "*****.amazonaws.com/itapp", "command": [ "bash", "-c", "", "python manage.py collectstatic --noinput && python manage.py makemigrations && python manage.py migrate && gunicorn itapp.wsgi -b 0.0.0.0:8000" ], "user": null, "dockerLabels": null, "logConfiguration": null, "cpu": 0, "privileged": null }, { "volumesFrom": null, "memory": 300, "extraHosts": null, "dnsServers": null, "disableNetworking": null, "dnsSearchDomains": null, "portMappings": … -
Allow certain group and admin to view part of HTML in Django
I'm trying to make it so that a certain part of the html is only viewable if a user belongs to a certain group or is an admin. I managed to find a way to make it so that only a certain group can see it: base.html {% for group in user.groups.all %} {% if group.name == 'example' %} Insert html here {% endif %} {% endfor %} The problem comes in trying to allow the admin to see it too. When I tried to add something like request.user.is_staff to the if statement, the code basically just ignored it. Is there anyway allowing the admin to see this html regardless of group without having to add the admin to the group? Also, this is the base.html, so trying to do this with a Python module would be problematic. -
Creating a login system that has custom fields in Django
I want to figure out how to create a sign-up system in Django that has custom fields. I want it to look something like this: Username Password Role (Dropdown) Developer Content Creator Staff Then just a basic login with user and pass and logout. -
Django static files not found Value error
I'm working on a project using cookiecutter django template: https://github.com/pydanny/cookiecutter-django The project is run in docker containers that come with the cookiecutter-django template on ubuntu 16.04LTS. When trying to get the site to production, it returns the following error on some pages: the file 'events\css\themes\fontawesome-stars.css' could not be found with <whitenoise.storage.CompressedManifestStaticFilesStorage object at 0x7f830be38ac8>. folder structure is: ./project/events/static/ └── events ├── css ├── details.css ├── list.css └── themes ├── fontawesome-stars.css └── fontawesome-stars-o.css No errors are reported during docker build process and after that running collectstatic. Permissions for the files on the server are set to 775. static config in base.py config: # STATIC FILE CONFIGURATION # ------------------------------------------------------------------------------ # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root STATIC_ROOT = str(ROOT_DIR('staticfiles')) # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url STATIC_URL = '/static/' # See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS STATICFILES_DIRS = [ str(APPS_DIR.path('static')), ] # See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders STATICFILES_FINDERS = [ 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ] -
Line Breaks and rendering HTML in Django Rest Framework's ValidationError
Working on a Django/DRF-React-Redux project. So I want to return specific messages for user login validation. If the credentials don't match, they get one error string, if the user is inactive they get another error string. What I am trying to do is for one of the messages I need two line breaks and the other I want to render HTML because it should contain an email address. Anything I have read on SO, is not working. For example, regarding the HTML: Put HTML into ValidationError in Django Here is the method: def validate(self, data): username = data['username'] password = data['password'] user_qs = User.objects.filter(username__iexact=username) # user_b = User.objects.filter(email__iexact=username) # user_qs = (user_a | user_b).distinct() if user_qs.exists() and user_qs.count() == 1: user_obj = user_qs.first() password_passes = user_obj.check_password(password) if not user_obj.is_active: raise ValidationError((mark_safe('This user is inactive. Please contact The Company at <a href="mailto:accounts@example.com?subject=Inactive Account">accounts@example.com</a>.'))) if password_passes: data['username'] = user_obj.username payload = jwt_payload_handler(user_obj) token = jwt_encode_handler(payload) data['token'] = token return data raise ValidationError('The credentials provided are invalid.\nPlease verify the username and password are correct.') Needless to say it isn't rendering as expected on the front-end. Doesn't break the lines and doesn't render HTML, just just displays it as typed. I guess if all … -
Supervisor FATAl Exited too quickly (process log may have details(About inet_http_server and unix_http_server)
I wrote a Django project and I use supervisor with gunicorn /etc/supervisor/conf.d/weather.conf [group:weather_station] programs=site [program:site] directory=$PROJECT command=/home/nhcc/.local/bin/gunicorn -c /$PROJECT/weather_station/gunicorn.conf.py -p gunicorn.pod weather_station.wsgi autostart=true autorestart=true stdout_logfile=/var/log/supervisor.log environment=my-environment-variable ~ sudo supervisorctl reread sudo supervisorctl reload sudo supervisorctl status It showed up the error weather_station:site FATAL Exited too quickly (process log may have details) So I checked out the log file : /var/log/supervisor/supervisord.log 2017-09-08 17:15:25,000 CRIT Supervisor running as root (no user in config file) 2017-09-08 17:15:25,000 WARN Included extra file "/etc/supervisor/conf.d/weather.conf" during parsing 2017-09-08 17:15:25,007 INFO RPC interface 'supervisor' initialized 2017-09-08 17:15:25,008 CRIT Server 'inet_http_server' running without any HTTP authentication checking 2017-09-08 17:15:25,008 INFO RPC interface 'supervisor' initialized 2017-09-08 17:15:25,008 CRIT Server 'unix_http_server' running without any HTTP authentication checking 2017-09-08 17:15:25,008 INFO supervisord started with pid 32371 2017-09-08 17:15:26,013 INFO spawned: 'site' with pid 32447 2017-09-08 17:15:26,018 INFO exited: site (exit status 127; not expected) 2017-09-08 17:15:27,022 INFO spawned: 'site' with pid 32448 2017-09-08 17:15:27,026 INFO exited: site (exit status 127; not expected) 2017-09-08 17:15:29,032 INFO spawned: 'site' with pid 32449 2017-09-08 17:15:29,038 INFO exited: site (exit status 127; not expected) 2017-09-08 17:15:32,043 INFO spawned: 'site' with pid 32451 2017-09-08 17:15:32,059 INFO exited: site (exit status 127; not expected) 2017-09-08 17:15:33,060 INFO … -
Pass Javascript Variable to Django Views
I am a beginner in Django and wrote a script code but i am not able to pass the variable to django views.py var selectedDataSet = new String('test'); function getDataSet() { var dataSetList = document.querySelector('#list'); selectedDataSet = dataSetList.options[dataSetList.selectedIndex].value; console.log(selectedDataSet) return selectedDataSet; } this is working perfectly, but i dont know how to pass selectedDataSet to Django views.py. -
How I should write test to Django views.py with slug
I try write tests.py to my views. I have issue with write a good test to view with slug. views.py: def post_detail(request, slug): post = Post.objects.get(slug=slug) context = {'post': post} template = 'post/post_detail.html' return render(request, template, context) Url looks like : post/slug_name, and slug is unique for every post. I try: tests.py class PostDetailTestCase(TestCase): def test_post_detail_(self): test = Post(title='poost', description="posting", category="letstest", slug='django') response = self.client.get(reverse('board_detail', args=(self.slug,))) self.assertEqual(response.status_code, 200) Run test error: response = self.client.get(reverse('post_detail', args=(self.slug, AttributeError: 'PostDetailTestCase' object has no attribute 'slug' How I should repair it? Thanks in advance. -
Get field values from manytomany relationship in Django model
I am trying to get field values which is associated with another model. The model Category has a manytomany relationship with Profile model. Category id category_name module_name 1 A X 2 B Y profile_category id profile_id category_id 1 2 1 For eg. I would like to display the module name X if category id 1 is assigned to the user id 2 models.py class Category(models.Model): category_name = models.CharField(max_length=150, blank=False, null=True, default="", unique=True) module_name = models.TextField(blank=False, null=True) class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, related_name ='profile') phone_number = PhoneNumberField( blank=True, null=True) organisation = models.CharField(max_length=30, blank=True) category = models.ManyToManyField(Category) # Get the list of module names I tried with module_name = Coupling.objects.values('module_name') but this is returning all the module_names not the names which are associated with user id 2 Any help/suggestion is highly appreciated. Thanks in advance. -
Django Rest Framework Change Password
I will add the password change feature in the API using Django Rest framework. But it would be correct to write this as a service and recognize UserChangePassword in serializer.py or write it in UserViewSet in api_views.py. Which one is clearer? why ? -
Mezzanine ignores the view, displays the template but does not pass the context
I created a view for my model, with the corresponding urls and template files. Then, in the admin panel, I have created a Rich text page, specifying the same URL (ingredients) defined in urlpatterns. Mezzanine ignores the view, displays the template but does not pass the context. How can I solve it? These are the codes: models.py from django.db import models from mezzanine.pages.models import Page from django.utils.translation import ugettext_lazy as _ class Ingredient(Page): name = models.CharField(max_length=60) information = models.TextField(null=True, blank=True, verbose_name=_("Description")) views.py from django.template.response import TemplateResponse from .models import Ingredient def ingredients(request): ingredients = Ingredient.objects.all().order_by('name') templates = ["pages/ingredients.html"] return TemplateResponse(request, templates, {'ingredients':ingredients}) urls.py from django.conf.urls import url from .views import ingredients urlpatterns = [ url("^$", ingredients, name="ingredients"), ] -
uWSGI python Fatal Python error: Py_Initialize: Unable to get the locale encoding
I'm trying to setup uWSGI nginx Django application and get the below error in uwsgi logs Sat Sep 9 13:01:48 2017 - Python version: 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609] Sat Sep 9 13:01:48 2017 - Set PythonHome to /home/ubuntu/.virtualenvs/app_name Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings' I'm using python 3.6 in virtualenv however not sure why uwsgi uses python version: 3.5.2. Will this be causing the error? uWSGI config that I have used [uwsgi] # variables project = app_name username = ubuntu base = /home/%(username)/app_name # config chdir = %(base) home = /home/ubuntu/.virtualenvs/%(project) module = %(project).wsgi:application master = true processes = 4 die-on-term = true vacuum = true socket = %(base)/%(project).sock chmod-socket = 664 uid = ubuntu guid = www-data logto = /var/log/uwsgi/uwsgi.log daemonize = /var/log/uwsgi/emperor.log env = DJANGO_SETTINGS_MODULE=settings.dev -
Can an ajax function accept a rendered Html page(in django) as a parameter to the callback function.?
Can an Ajax call render a page dynamically as Html content and include it in a Django template?. To be more precise I want to query the comments of a particular article on the existing page on the click of a comments link. I am not able to get whats wrong with my code. On clicking the comment link I am getting the comments box displayed but not the comments. In the console I am getting the value of myvar displayed. $(document).ready(function(){ $("ul.stream").on("click", ".comment", function(event){ var post = $(this).closest(".post"); if ($(".comments", post).hasClass("tracking")) { $(".comments", post).slideUp(); $(".comments", post).removeClass("tracking"); } else { $(".comments", post).show(); $(".comments", post).addClass("tracking"); $(".comments input[name='post']", post).focus(); var myvar= $(post).closest("li").attr("post_id"); console.log(myvar); $.ajax({ url: '/articles/comment/', type: 'GET', data:{post_id: myvar}, <!-- dataType:'json', --> success: function(data) { $("ol", post).html(data) ; } }); } return false; }); }); </script> //all_articles.html <ul class="stream"> {% for article in all_articles %} {% include 'articles/indivisual_article.html' with article=article %} {% endfor %} </ul> //indivisual_article.html <li post_id="{{article.id}}" csrf="{{csrf_token}}"> <div class="post"> <div id="second"> <a href="#" style="text-decoration: none;" class="comment" id="allcomments" value="{{article.id}}"> <span class="glyphicon glyphicon-comment"></span> {% trans 'Comment' %} (<span class="comment-count">{{article.articlecomment_set.count }}</span>) </a> </div> <div class="comments"> <form role="form" method="post" action="{{ comment }}" onsubmit="return false"> {% csrf_token %} <input type="hidden" name="post_id" value="{{ article.id }}"> … -
django login does't work
login() does't work in my project my views.py @csrf_exempt def login(request): if request.method == 'POST': Email = request.POST['Email'] Password = request.POST['Password'] u = authenticate(request, Password=Password, Email=Email) if u is not None: login_auth(request, u) return redirect('account') else: context = {'message_error': 'invalid login'} return render(request, 'account/login.html',context) else: return render(request, 'account/login.html') and my models.py class user(models.Model): id = models.AutoField(primary_key=True) User = models.CharField(max_length=80,default='',null=True) Password = models.CharField(max_length=50,default='',null=True) Email = models.CharField(max_length=60,default='',null=True) i try it just answer 'invalid login' please help me -
Most efficient way using WebSockets on all pages of website?
I am using Django v1.11 and django-channels for web socket server. Website has user auth and each user can send messages to others and invite users to room (groups). There can be more than 1000+ rooms that one person can be connected. To connect to room I use this code in consumers.py: @channel_session_user_from_http def ws_connect(message): ... for room in user_rooms: Group("chat-%s" % room).add(message.reply_channel) Each page has javascript code: var socket = new WebSocket('ws://' + window.location.host + '/chat'); socket.onmessage = function(e) { ... }; I want users to be alerted about new messages in groups on all website pages. 1) Is it good practice to use ws_connect() each time when user loads new page? If no, what is the best way for good speed? 2) Is it okey to Group(..).add(..) more then 1000+ times and user will be connected to all that group at the same time for performance? What is the best way to archive this? -
Upload Image file and send to rest API
import { Component } from '@angular/core'; import { Http, RequestOptions, Headers, Response } from '@angular/http'; import { Observable } from 'rxjs/Rx'; @Component({ selector: 'my-app', templateUrl: './app/app.component.html', styleUrls: ['./app/styles/styles.css'] }) export class AppComponent { private isUploadBtn: boolean = true; constructor(private http: Http) { } //file upload event fileChange(event) { debugger; let fileList: FileList = event.target.files; if (fileList.length > 0) { let file: File = fileList[0]; let formData: FormData = new FormData(); formData.append('uploadFile', file, file.name); let headers = new Headers() headers.append('Content-Type', 'json'); headers.append('Accept', 'application/json'); let options = new RequestOptions({ headers: headers }); let apiUrl1 = "/api/UploadFileApi"; this.http.post(apiUrl1, formData, options) .map(res => res.json()) .catch(error => Observable.throw(error)) .subscribe( data => console.log('success'), error => console.log(error) ) } window.location.reload(); } } <div class="fileUpload btn btn-primary" *ngIf="isUploadBtn"> <span>Upload</span> <input type="file" id="btnUpload" value="Upload" (change)="fileChange($event)" class="upload" /> </div> I have implemented above code, which is handle by django REST API . But it show 415 status code that is Unsupported media type...! while when I am send same request through POSTMAN It accepts. My curl command is curl -X POST \ http://192.168.1.223:8010/profilepic/ \ -H 'authorization: Basic OTc5Nzk3OTc5NzoxMjM=' \ -H 'cache-control: no-cache' \ -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \ -H 'postman-token: b9cbe00a-310e-da51-63fa-fcfaed26435f' \ -F 'datafile=@/home/ashwini/Pictures/Screenshot from 2017-08-17 18-19-31.png'