Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
reportlab install error in django app
I want to install reportlab to make pdf file from python script. But I got the following error. Exception: Traceback (most recent call last): File "/home/ubuntu/remoshindev/lib/python3.5/site-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/home/ubuntu/remoshindev/lib/python3.5/site-packages/pip/commands/install.py", line 342, in run prefix=options.prefix_path, File "/home/ubuntu/remoshindev/lib/python3.5/site-packages/pip/req/req_set.py", line 784, in install **kwargs File "/home/ubuntu/remoshindev/lib/python3.5/site-packages/pip/req/req_install.py", line 922, in install with open(inst_files_path, 'w') as f: FileNotFoundError: [Errno 2] No such file or directory: './lib/python3.5/site-packages/olefile-0.44-py3.5.egg-info/installed-files.txt' I don't have a "./lib/python3.5/site-packages/olefile-0.44-py3.5.egg-info/installed-files.txt". How can I fix it? Please let me know. -
source .env doesn't work
My .env file is: export DJANGO_SETTINGS_MODULE=taxi_framework.settings.local export TAXI_DASHBOARD_RAVEN_DSN="" export TAXI_LOCATION_BACKEND_URL='http://localhost' export TAXI_DASHBOARD_BOOKING_BACKEND_URL='http://localhost' export SECRET_KEY='here is my secret key' export TAXI_DASHBOARD_DEFAULT_DATABASE="mysql://root:rootroot@127.0.0.1/namba_taxi" I ativate it with source .env command and got .env.save file, but when I ran django project I got missing SECRET_KEY mistake. How to make this file work? -
Django: Messages not being displayed
I have following function for bulk operation of the selected rows in a ListView. I am showing messages for success and error. def archive_stores(view, queryset): if queryset.exists(): queryset.update(archive=True) success_message = messages.success(view.request, 'Archived successfully.') return HttpResponseRedirect(reverse('stores_list', success_message)) else: #The message is not shown when queryset of empty. error_message = messages.error(view.request, 'No success!.') return HttpResponseRedirect(reverse_lazy('stores_list', error_message)) The success message is being displayed correctly. But the Error message never appears. Please guide me what can be the reason? Thanks. -
Django Rest Framework add page number attribute using the PageNumberPagination class
I am building an API in Django and I am trying to add the page number on the json results. And I am trying to add the page number in the returned results for example, I am currently getting this; { "links": { "next": null, "previous": null }, "count": 1, "results": [ { "url": "http://127.0.0.1:8000/api/brands/1/?format=json", "name": "microsoft", "description": "Nothing", "top_brand": true, "guid": "microsoft" } ] } But I am trying to get something like this; { "count": 1, "results": [ { "url": "http://127.0.0.1:8000/api/brands/1/?format=json", "name": "microsoft", "description": "Nothing", "top_brand": true, "guid": "microsoft" }, ... ], "page_number": 1, "from": 1, "to": 10, "last_page": 4 } The most important attribute is the page_number but I am not so sure how to get that from the parent class using self... I see no direct way besides using a function. Here is my code; class StandardResultsSetPagination(PageNumberPagination): page_size = 100 page_size_query_param = 'page_size' max_page_size = 1000 def get_paginated_response(self, data): return Response({ 'links': { 'next': self.get_next_link(), 'previous': self.get_previous_link() }, 'count': self.page.paginator.count, 'results': data, 'page_number': self.page.paginator.count, }) -
How to enable default error views in Django 1.11?
I upgraded a Django project to 1.11, and now some of the default error views don't work anymore. I have these settings: handler500 = 'myhandle_500' handler404 = 'myhandle_404' handler403 = django.views.defaults.permission_denied However, I've implemented a simple test view for the 403 error, which just raises a PermissionDenied exception, and while this used to show my custom 403.html template, now it's treated like a generic server exception and shows my 500.html template. How do I restore this functionality? -
How to run a python script inside javascript and refresh the view in django
I have a python script that takes in some data and manipulates it. However i need it to run on the client side inside the javascript to process some data and refresh the view. The python file that manipulates data works well as I have tested it inside the IDLE shell DataManipulation.py class ModifyData(object): #Bunch of functions to manipulate data below is the function used to render the view with url '.../test' which also works perfectly. views.py def test(request): template = 'app/test.html' file = 'documents/Sample.csv' #File to be loaded args = {'test': file } return render(request, template, args) After loading this page, i use a javascript library that displays the data on the page in a table, the user can then manipulate the data like multiply a column by 3, but where I am stuck is how to take my DataManipulation.py file to modify the data and updates the page with the updated column on a button click -
How do I fix my Createview in Django
I am trying to make a business card manager using django python but I don't why my business card are not being added and when press the button Add business Card it goes to the business Card list blank. I also want to know how to make the delete and update button work on the Business Card List. I think you have to add a primary key in the model but I don't know how to and how to pass it in correctly. Views from django.views import generic from django.views.generic.edit import CreateView, UpdateView, DeleteView from django.core.urlresolvers import reverse_lazy from django.shortcuts import render, redirect from django.contrib.auth import authenticate, login from django.views.generic import View from .models import BusinessInfo class BusinessCardListView(generic.ListView): model = BusinessInfo template_name = 'manager/BusinessCardList.html' context_object_name = 'all_business_cards def get_queryset(self): return BusinessInfo.objects.all() class BusinessCardCreate(CreateView): model = BusinessInfo fields = ['card', 'company_name', 'phone_number', 'website', 'representative_name', 'branch_address', 'job_title', 'fax_number', 'cell_phone_number', 'email'] class BusinessCardUpdate(UpdateView): model = BusinessInfo fields = ['card', 'company_name', 'phone_number', 'website', 'representative_name', 'branch_address', 'job_title', 'fax_number', 'cell_phone_number', 'email'] class BusinessCardDelete(DeleteView): model = BusinessInfo success_url = reverse_lazy('manager:index') Add Business Card form {% extends 'manager/base.html' %} {% block title %}Add a New Business Card{% endblock %} {% block albums_active %}active{% endblock %} {% block body … -
Change value in xlsx file with openpyxl
I parse data from xlsx file with openpyxl and than pass it to template. Parsing: def load_table(filename): wb = xls.load_workbook(filename=filename) ws = wb.worksheets[0] return list(ws.rows) def parse_date(row): text = row[0].value rs = text.split(' ') for r in rs: if len(r) == 11 and len(r.split('.')) == 4: return r def parse_data(rows): data = {} class_name = '' for row in rows: if row[-1].value is None: class_name = row[0].value.replace('-', '') if class_name not in data: data[class_name] = [] elif ':' not in row[0].value: data[class_name] += [[row[0].value, row[1].value]] return data def parse_table(filename): rows = load_table(filename) date = parse_date(rows[0]) data = parse_data(rows[2:]) return date[:-1], data data: {'1A': ['Name1', 'State1', 'Name2', 'State2'], '1B': ['Name1', 'State1', 'Name2', 'State2', 'Name3', 'State3', 'Name4', 'State4', 'Name5', 'State5'], '1C': ['Name1', 'State1'] ...} Users can change states and post it to server. In view i handle request in dict: if 'school' in request.POST: for k, v in request.POST.lists(): changed_data_values.append(v) for i in changed_data_values[1]: key = i tmp_dict[key] = list(zip(changed_data_values[2], changed_data_values[3])) dict: {'1B': [('Name1', 'State1'), ('Name2', 'State2'), ('Name3', 'State3'), ('Name4', 'State4'), ('Name5', 'State5')]} The question is how change value of state in xlsx file? I will be very grateful for any help. This is the last thing left to do in the … -
django project avoid reload page where work algorithm
I have a website where the user can be put three numbers on my html template and get some results from my personal mathematical algorithm. the result save at user personal table on my database and can see in specific tab in my website. my problem is where the algorithm to calculate result maybe take time between 5-10 minutes in this time the browser stay on reload. if user change tab or close browser or maybe have problem with internet connection then loose that request and need again to put the numbers and again wait for results. I want after the user request from my form in html to keep this request and work my algorithm without reload the page and where the algorithm finish then to send the user some email or message or just need the user visit the tab of results to see new results. that I want to avoid the problems where the algorithm is in running and user loose data or request or time. is easy to do that using suproccess,celery or RabbitMQ ? any idea ? here the code views.py def math_alg(request): if request.method == "POST": test = request.POST.get('no1') test = request.POST.get('no3') test = … -
Jwt Decode using PyJWT raises Signature verification failed
I'm running into a weird issue with decoding the jwt token in the django views. If I try jwt.decode('encoded_token', 'secret') then I see the "Signature verification failed" message. In order to escape from this issue I've set the verify flag to False: jwt.decode('eroded_token', 'secret', verify=False) This gives the decoded payload with no error but I'm trying to figure out how I can verify the token successfully without setting the verify flag to False. Any Ideas? Thanks -
django collectstatic with settings flag throws logging path error using incorrect logging path
I've recently started restructuring a project to use two scoops style configuration, with a config package, with settings inside it. Within that package, there's _base.py, development.py, staging.py and production.py. Since this is deployed as a WSGI app with Apache, I'm using a json file for environment variables, such as AWS credentials, db username/passwords and such. In short, following suggestions listed at https://medium.com/@ayarshabeer/django-best-practice-settings-file-for-multiple-environments-6d71c6966ee2 When deploying on staging, I have the wsgi app running through apache. In addition, manage.py $COMMAND is working with the --settings=config.settings.staging flag set. That is, with the exception of collectstatic. It's apparently trying to access an invalid logging path, and I can't figure out why its using that particular path which is not defined in the settings file being used. Current output of collectstatic run: (staging)ubuntu@farmer-stage:~/public_html/django/project$ ./manage.py collectstatic --help Using configuration [config.settings.staging] Using configuration [config.settings.staging] Traceback (most recent call last): File "./manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/home/ubuntu/.virtualenvs/staging/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line utility.execute() File "/home/ubuntu/.virtualenvs/staging/lib/python2.7/site-packages/django/core/management/__init__.py", line 328, in execute django.setup() File "/home/ubuntu/.virtualenvs/staging/lib/python2.7/site-packages/django/__init__.py", line 17, in setup configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) File "/home/ubuntu/.virtualenvs/staging/lib/python2.7/site-packages/django/utils/log.py", line 86, in configure_logging logging_config_func(logging_settings) File "/usr/local/lib/python2.7.11/lib/python2.7/logging/config.py", line 794, in dictConfig dictConfigClass(config).configure() File "/usr/local/lib/python2.7.11/lib/python2.7/logging/config.py", line 576, in configure '%r: %s' % (name, e)) ValueError: Unable to configure … -
Extending Django filer image model to add category
I recently had problems with extending django filer, probably my knowledge about django is not sufficient yet. Basically what I would like to achieve is to extend django filer image model to be able to add category to images. Of course would be nice to have manytomany relation to category model. Could you help me with this topic? -
Using Django-bootstrap3 . How to target individual form fields to adjust CSS
Here is my code below. I need to be able to adjust the appearance of the individual fields and labels in the CSS but I am not sure how to do this for the code below. Basically the question how to I know what class or ID selector I need to target or what settings I need to use <form action="/post/" method="post" class="form"> {% csrf_token %} {% for field in form %} {% bootstrap_field field layout='inline' %} {% endfor %} {% buttons %} <button type="submit" class="btn btn-success"> {% bootstrap_icon "pencil" %} Post </button> <button type="reset"> {% bootstrap_icon "erase" %} Clear </button> {% endbuttons %} </form> I am a complete newbie for this. I have been through the docs but I am not sure where to start -
Django runnning on heroku: have to login again after every dyno restart
I am running a django web app on Heroku. I'm using the hobby-dev plan, so the dyno doesn't go to sleep after inactivity, but it does restart once per day. After every restart, I need to re-enter my login credentials to use the admin interface. How can I make my login session persist after a dyno restart? -
Problems with MongoDB and Python
Good evening guys, I need some help. I need to implement a MongoDB database as a default or secondary (if possible) in an application made in Django. Currently my Django application works with Tweepy, I need to save the captured data in the NoSQL database. I chose MongoDb, but I found several information saying that it is only possible to use with python 2.7 (my application was built in python 3.5). Is there any way to do it? I have already tried to use pymongo, mongodbengine, among others without success ... I believe that I am not doing correct. I need guidance in this process (I did not find information for newer versions of django and python, and the documentation has not been updated) -
Delete confirmation in django
I am working on a project in django. I have this part of code, when I want to delete an album, it shows Yes or No to choose, but the problem is, whatever the choice I make, it always delete the album. I know I have to add something to the confirmation option but I don't want where or what. <form action="{% url 'music:delete_album' album.id %}" method="post" style="display: inline;"> {% csrf_token %} <input type="hidden" name="album_id" value="{{ album.id }}" /> <button type="submit" onclick="confirm('Are you sure ?')" class="btn btn-default btn-sm"> <span class="glyphicon glyphicon-trash"></span> </button> </form> and this is the delete_album view : def delete_album(request, album_id): album = Album.objects.get(pk=album_id) album.delete() albums = Album.objects.filter(user=request.user) return render(request, 'music/index.html', {'albums': albums}) -
Calculate Django Data query according to date
This is my models.py file. class CustomerInfo(models.Model): customer_name=models.CharField('Customer Name', max_length=50) customer_mobile_no = models.CharField('Mobile No', null=True, blank=True,max_length=12) customer_price=models.IntegerField('Customer Price') customer_product_warrenty = models.CharField('Product Warrenty',null=True, blank=True,max_length=10) customer_sell_date = models.DateTimeField('date-published') customer_product_id=models.CharField('Product ID',max_length=150,null=True, blank=True) customer_product_name=models.CharField('Product Name', max_length=50) def __str__(self): return self.customer_name When I find data query information by date, I want to calculate "customer_price" by only selected date. Then I will show to my HTML page. This is my search query by date. customers = CustomerInfo.objects.filter(customer_sell_date__day=datelist) Now, Calculate all ""customer_price"" within my selected date. -
Heroku sais: "Requested setting LOGGING_CONFIG" but it is set?
I'm trying to setup a Django site on Heroku. I get this error message: 2017-10-07T21:03:33.416585+00:00 app[web.1]: django.core.exceptions.ImproperlyConfigured: Requested setting LOGGING_CONFIG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. But if I run Heroku config, the var is set. Why is it not recognized? === dagenssalg Config Vars DISABLE_COLLECTSTATIC: 0 LOGGING_CONFIG: off Many answers in here mention the wsgi.py file, but I can't see anything wrong with that: import os from django.core.wsgi import get_wsgi_application from django.core.wsgi import get_wsgi_application from whitenoise.django import DjangoWhiteNoise application = get_wsgi_application() application = DjangoWhiteNoise(application) os.environ.setdefault("DJANGO_SETTINGS_MODULE","dagenssalg.settings") application = get_wsgi_application() Any help is most appreciated. Best regards Kresten -
Filter objects by exact position of character through a variable
code: 1)CSE-101 2)CSE-102 3)CSE-101 4)CSE-204 5)CSE-106 6)CSE-201 position: 012345678 i want to make a search for the value which is stored in variable . suppose,I want' to make a search for all the codes with 2 at position 4. So the search should return the 4th and 6th code. I've looked at django look_up functions. Is there a way to make a search like this? this is correct regular expression for desired output,in the case of direct use of numerical number 2. Model.objects.filter(code__regex=r'^.{4}2') but i want make a regular expression like that .suppose s=2, then i want to include s with this regular expression. -
how to solve django social auth error on facebook?
i installed social-auth-app-django and followed the guide here to integrate facebook login to django 1.8.18 .The problem is when i go to "http://localhost:8000/social-auth/login/facebook/" I get below error Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings. Here is my settings.py file # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) print (BASE_DIR) SECRET_KEY = 'x220#z=kwd)kjiu#u+p$)v0lu+rspyosg+)l*k$ux9j)1h' DEBUG = True ALLOWED_HOSTS = ['localhost'] INSTALLED_APPS = ( ... 'account', 'social_django', #social classes ) MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', 'social_django.middleware.SocialAuthExceptionMiddleware', ) ROOT_URLCONF = 'bookmark.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'social_django.context_processors.backends', # <-- 'social_django.context_processors.login_redirect', # <-- ], }, }, ] WSGI_APPLICATION = 'bookmark.wsgi.application' STATIC_URL = '/static/' MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR,'media/') from django.core.urlresolvers import reverse_lazy LOGIN_REDIRECT_URL = reverse_lazy('dashboard') LOGIN_URL = reverse_lazy('login') LOGOUT_URL = reverse_lazy('logout') AUTHENTICATION_BACKENDS = ( 'social_core.backends.facebook.FacebookOAuth2', #< --facebook 'django.contrib.auth.backends.ModelBackend', 'account.authentication.EmailAuthBackend', ) SOCIAL_AUTH_FACEBOOK_KEY='1742581762468139' SOCIAL_AUTH_FACEBOOK_SECRET='eae7dsfdsfdsf90b219becb84' urls.py file from django.conf.urls import include, url from django.contrib import admin from django.conf import … -
Using another apps model as Foreign Key
The error I'm getting. insert or update on table "soccer_game" violates foreign key constraint "soccer_game_match_id_7834e80f_fk_soccer_match_id" DETAIL: Key (match_id)=(6) is not present in table "soccer_match". I have an app for creating matches called home. It has a Match model in it. # home.models.py from django.db import models class Match(models.Model): pick = models.CharField(max_length=30, choices=GAMES) name = models.CharField(max_length=30) created = models.DateTimeField(auto_now_add=True) players = models.IntegerField(choices=NUM_PLAYERS) def __str__(self): return self.name class Meta: verbose_name_plural = "matches" The GAMES choices is a list of all the other sport/game apps. One of them is soccer which has these models. # soccer.models.py from django.conf import settings from django.db import models from home.models import Match class Player(models.Model): name = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) number = models.IntegerField(default=0) score = models.IntegerField(default=0) def __str__(self): return self.name.username class Settings(models.Model): match = models.ForeignKey('home.Match') time = models.IntegerField(default=0) class Meta: verbose_name_plural = 'settings' def __str__(self): return self.match.name class Game(models.Model): match = models.ForeignKey('home.Match') player = models.ForeignKey(Player) def __str__(self): return self.match.name Then in the home app the view to create a match. # home.views.py from .forms import MatchForm from home.models import Match from soccer.models import Game, Player, Settings # Create your views here. @login_required def create_match(request): form = MatchForm(request.POST or None) context = { 'form': form, } if request.method == 'POST': … -
Fail to create a superuser in django, when use a router
I tring to create mongodb/mysql project on Djago 1.11.4 with python3. I intended to use mysql for user authentification and mongodb for all other purposes. I master to create a users but failed in creating a superuser. Here is what happend, when I tried to create a superuser: $ python3 manage.py createsuperuser username=Admin System check identified some issues: WARNINGS: ?: (urls.W001) Your URL pattern '^$' uses include with a regex ending with a '$'. Remove the dollar from the regex to avoid problems including URLs. Email address: admin@example.com Password: Password (again): Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 363, in execute_from_command_line utility.execute() File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 355, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 283, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/management/commands/createsuperuser.py", line 63, in execute return super(Command, self).execute(*args, **options) File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 330, in execute output = self.handle(*args, **options) File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/management/commands/createsuperuser.py", line 183, in handle self.UserModel._default_manager.db_manager(database).create_superuser(**user_data) File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/models.py", line 170, in create_superuser return self._create_user(username, email, password, **extra_fields) File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/models.py", line 153, in _create_user user.save(using=self._db) File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/base_user.py", line 80, in save super(AbstractBaseUser, self).save(*args, **kwargs) File "/usr/local/lib/python3.5/dist-packages/django/db/models/base.py", line 807, in save force_update=force_update, update_fields=update_fields) File "/usr/local/lib/python3.5/dist-packages/django/db/models/base.py", line 834, in save_base with transaction.atomic(using=using, savepoint=False): File "/usr/local/lib/python3.5/dist-packages/django/db/transaction.py", line 158, … -
Django include - render content inside block
How can I render contents of header-actions block in page.html to master template. Currently, the block isn't rendered. header.html <header> {% block header-actions %}{% endblock %} </header> master.html <html> <body> {% include 'header.html' %} Some content </body> </html> page.html {% extends 'master.html' %} {% block header-actions %} Extra action {% endblock %} -
Consume kafka messages from django app
I'm designing a django based web application capable of serving via Web sockets data that need to be consumed from Kafka topic. At this time, I came up with a solution splitted in two components: one component which consumes from kafka, perform some basic operations over retrieved data, and send the result to the django app using an http request. After request have been received, a message is written over a specific django channel. Is there a better architecture to address this kind of scenario? Should I enclose all the Kafka part in a "while True" loop in a celery async task? Should I spawn a new process when django starts? If so, can I still use the django signals to send the data via web socket? Thanks, Fb -
Setting up sockets on Django
Have a django project with django-channels (using redis) allows uset to start background process and should get back a live feed of this on the page. Here's a recording of this: https://youtu.be/eKUw5QyqRcs Sockets disconnects with a 404. Here's the socket's code: $('.test-parse').unbind().click(function() { ... $.ajax({ url: "/start-render-part", type: "POST", dataType: 'json', beforeSend: function(xhr, settings) { if (!csrfSafeMethod(settings.type) && sameOrigin(settings.url)) { // Send the token to same-origin, relative URLs only. // Send the token only if the method warrants CSRF protection // Using the CSRFToken value acquired earlier xhr.setRequestHeader("X-CSRFToken", csrftoken); } }, data: JSON.stringify(data), success: function(response){ if (response['status'] == 'ok') { if (response['unique-id']) { unique_processing_id = response['unique-id']; } if (response['task_id']) { task_id = response['task_id']; } var add_to_group_msg = JSON.stringify({ 'unique_processing_id': unique_processing_id, 'task_id': task_id, 'command': 'add_to_group', }); var socket = new WebSocket("ws://{HOST}/render-part/".replace('{HOST}', window.location.host)); socket.onopen = function() { console.log('opened'); var add_to_group_msg = JSON.stringify({ 'unique_processing_id': unique_processing_id, 'task_id': task_id, 'command': 'add_to_group', }); socket.send(add_to_group_msg); var get_status_msg = JSON.stringify({ 'task_id': task_id, 'unique_processing_id': unique_processing_id, 'command': 'check_status', }); socket.send(get_status_msg); }; socket.onmessage = function(event) { console.log("onmessage. Data: " + event.data); var data = JSON.parse(event.data); if (data.state == 'PROGRESS') { console.log(data.status); update_progress(data.current); } else if (data.state == 'FINISHED') { var remove_from_group_msg = JSON.stringify({ 'unique_processing_id': unique_processing_id, 'command': 'remove_from_group', }); socket.send(remove_from_group_msg); unique_processing_id = …