Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django - zip selected image when download
I have retrieved the image id when user click checkbox. How to zip the selected image when user click download? -
GitLab CI with multiple repository dependencies
With my Django setup I have the main project as a repo and then for each Django app that lives in the project another repo. This is so that each app has its own repository on something like GitLab for example. When doing a GitLab CI config script it automatically pulls in the code from the main repo as this is where the gitlab-ci script is located. Other than faffing with SSH keys and manually cloning by URL in the CI descriptor, is there any other way to tell GitLab to automatically pull in all the apps from there respective git URL to run the tests on? Example project structure. djangoproject djangoapp1 .git => http://gitlab.com/user/djangoapp1 djangoapp2 .git => http://gitlab.com/user/djangoapp2 djangoapp3 .git => http://gitlab.com/user/djangoapp3 ... other django files ... .git http://gitlab.com/user/djangoproject -
Integrating qgis2web into Django
I want to integrate a qgis2web-map into my djangoproject. The map will only be a small part of the project, so it would be pointless to setup a GIS-based djangoproject. When I make a "SimpleHTTPServer" request, the map turns up just fine in a browser. But if I point to the index.html file via django, only a blank page shows. The index-file is not able to load the static files, which comes with the qgis2web-package? I've tried different approaches like putting the static-files in django's static-folder (with {% load staic %} in the index-file) - yet again a blank page. Making a template is too complicatet for me, and I find it too much work for so small a thing. Is there a simple approach til integrate a qgis2web map into django? -
Django: Match multiple LDAP groups to is_staff flag
I'm trying to match multiple LDAP groups to the is_staff flags in django settings.py If I do LDAP or syntax: "is_staff" : "(|(cn=example)(cn=otherexample)) it doesn't match either if I pull the LDAP syntax outside the quotes: "is_staff" : (|("cn=example")("cn=otherexample")) it syntax errors. If I use python "Or": "is_staff" : "cn=example" or "cn=otherexample" It only matches the first one And if I use two "is_staff" flags: "is_staff" : "cn=example" "is_staff" : "cn=otherexample" It only matches the second one. Is there any way to match two different groups in django? Thanks. -
Django custom User model results in AttributeError: Manager isn't available; 'auth.User' has been swapped for 'authentication.User'
In my django app, called authentication, I created a custom user model, mostly following the django documentation. In a previous project of mine it used to work, but now when I say: user = User.objects.get(username=username) I'm constantly facing an error: AttributeError: Manager isn't available; 'auth.User' has been swapped for 'authentication.User'. I've tested it with both python2 and python3, django versions 1.9 and 1.10 What might be wrong? My code: models.py: from django.db import models from django.contrib.auth.models import AbstractBaseUser, \ BaseUserManager, PermissionsMixin from django.utils import timezone from django.utils.translation import ugettext_lazy as _ import uuid import base64 class UserManager(BaseUserManager): def create_user(self, username, email, name, password=None): user = self.model( username=username, email=email, name=name, last_login=timezone.now() ) # last_login is defined in AbstractBaseUser user.set_password(password) user.save(using=self._db) return user def create_superuser(self, username, password): user = self.create_user( username=username, email=None, name=username, password=password ) user.is_staff = True user.is_superuser = True user.save(using=self._db) return user def generate_registration_code(): return "asd" class User(AbstractBaseUser, PermissionsMixin): # This model should be created in the firest migration: # https://docs.djangoproject.com/en/1.9/topics/auth/customizing/#substituting-a-custom-user-model # We use username, not email as primary user id, because OAuth # implementation via python-social-auth requires this field to # be present. username = models.CharField( verbose_name=_('username'), max_length=255, unique=True ) email = models.EmailField(null=True, blank=True) # name is a human-readable … -
Django datatime field is autoadding 7 hours
I am copying data from one MySQL table into another in Django. article = Article.objects.get(id=10) article2 = ArchivedArticles(title=article.title, content= article.content, publishdate = article.publishdate) article2.save() However the publish date in ArchivedArticles table is changed to 7Hours+ for example if the publish date in Articles table is '2016-08-23 17:58:00' in ArticleArchived table it is '2016-08-24 00:58:00' publishdate for both tables is defined in the Models as publishdate = models.DateTimeField(null=True, db_column='PublishDate', blank=True, editable=False, verbose_name="Date") and in MYSQL it is as below for both tables publishdate TIMESTAMP NOTNULL Default = '0000-00-00 00:00:00' Any idea why is that happening? -
How to make simple graphs in python 2.7
I would like to make simple graphs for my web page in python/django, but I do not know, which library (and how) to use. Each such graph is probabely generated and used only one time, as next time the values would differ. I can simply compute the positions of all rectangles, lines or texts in it, so I would like something lightweight to just create pictre from that, which I would return as img/png (or so) mime style like <img src="http://my.web.www/my/page/graph" > where the parameters to show would be decidied by session and database. I can compute all the sizes beforehand, so I would like something simple like img=Image(PNG,598,89) # style, x, y img.add_text('1.3.', 10,10) img.add_rectagle(20,10, 70,20, CYAN, BLACK) .... return img.render() Can you direct me, how to do it? Thanks beforehand -
embed plotly table into a django template
i have been trying to embed pandas data with plotly-table onto my dgango template but i am unable to get it done, tried many times but i can't get it done, only i am able to show raw pandas data on my template file that's all. model.py file class Preprocess(): df = pd.read_csv('F:\lcdata.csv') df_sample = df.head() table = FF.create_table(df_sample) global table global df_sample def import_display(self): return df_sample #return iplot(table, filename='pandas_table') def draw_chart(self): plotly_url = plot(table, filename='pandas_table') pie_url = '<iframe width="200" height="200" frameborder="0" seamless="seamless" scrolling="yes" src='+plotly_url+'.embed?width=200&height=200&link=false&showlegend=false></iframe>' return pie_url this is my view.py file ..... def display_table(request): preprocess=Preprocess() return render(request, 'ml/index.html', { 'preprocess':preprocess}) this is my template index.html {% block title %} <h2>Latest reviews</h2> {% endblock %} {% block content %} <div class="row"> <div class="col-xs-6 col-lg-4"> <h4> {{ preprocess.import_display }}</h4> <div style="width:600;height:500"> {{ preprocess.draw_chart }} </div> </div> </div> {% endblock %} -
How to validate an email address in a form to be only as 'gmail.com'?
How to validate an email address in a form to be only as 'gmail.com' but raise an error if the domain name and extension is anything other than 'gmail.com'? I get an error if the email address ends with @gmail.au.com for example from django import forms from .models import User class RegisterForm(forms.ModelForm): class Meta: model = User fields = ['first_name', 'last_name', 'email', 'country'] def clean_email(self): email = self.cleaned_data.get('email') email_base, provider = email.split('@') domain, extension = provider.split('.') if domain == 'gmail' and extension != 'com': raise forms.ValidationError('Please enter a valid gmail address.') return email -
django bootstrap modal form redirect on validation failed
I have Bootstrap Modal which contains form. When validation form is failed redirect to the page form. The question is how to make that server send me response with errors in my modal form urls.py url(r'^add/$', CreateCarView.as_view(), name='add_auto'), views.py class CreateCarView(CreateView): model = Car template_name = 'automobiles/automobiles_add.html' fields = '__all__' def get_success_url(self): messages.success(self.request, 'Авто успішно додано') return reverse('home') def post(self, request, *args, **kwargs): if request.POST.get('cancel_button'): messages.info(self.request, 'Додавання відмінено') return HttpResponseRedirect(reverse('home')) else: return super(CreateCarView, self).post(request, *args, **kwargs) base.html <div class="row"> <div class="col-xs-4"> <button type="button" class="btn btn-warning" data-toggle="modal" data-target="#myModal" data-remote="{% url 'add_auto' %}"> Open Modal </button> <div id="myModal" class="modal fade" role="dialog"> <div class="modal-dialog modal-sm"> <!-- Modal content--> <div class="modal-content"> </div> </div> </div> </div> </div> automobiles_add.html <form id="add_item" class="form" role="form" action="{% url 'add_auto' %}" method="post"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title">Додати авто</h4> </div> <div class="modal-body"> {% csrf_token %} {{ form.as_p }} </div> <div class="modal-footer"> <input class="btn btn-success" type="submit" value="Додати тачку" name="add_button"> <input class="btn btn-danger" type="submit" value="Відмінити" name="cancel_button"> </div> -
Django with gunicorn and nginx: HTTP 500 not appearing in log files
I have a Django app running on a gunicorn server with an nginx up front. I need to diagnose a production failure with an HTTP 500 outcome, but the error log files do not contain the information I would expect. Thusly: gunicorn has setting errorlog = "/somepath/gunicorn-errors.log" nginx has setting error_log /somepath/nginx-errors.log; My app has an InternalErrorView the dispatch of which does an unconditional raise Exception("Just for testing.") That view is mapped to URL /fail_now I have not modified handler500 When I run my app with DEBUG=True and have my browser request /fail_now, I see the usual Django error screen alright, including the "Just for testing." message. Fine. When I run my app with DEBUG=False, I get a response that consists merely of <h1>Server Error (500)</h1>, as expected. Fine. However, when I look into gunicorn-errors.log, there is no entry for this HTTP 500 event at all. Why? How can I get it? I would like to get a traceback. Likewise in nginx-errors.log: No trace of a 500 or the /fail_now URL. Why? -
thumbnail creation crashes in easy_thumbnails.processors.background
I am using Django and easy-thumbnails 2.3. My intention is to take an image, scale it down so that it fits a square and fill the empty area with white color in case of non-square original images. Also in case of transparent images the transparency shall be changed to white. My settings.py contains the following lines: THUMBNAIL_PROCESSORS = ( 'easy_thumbnails.processors.colorspace', 'easy_thumbnails.processors.autocrop', 'easy_thumbnails.processors.scale_and_crop', 'easy_thumbnails.processors.filters', 'easy_thumbnails.processors.background', ) THUMBNAIL_ALIASES = { '':{ 'square_image': {'background':'#fff','replace_alpha':'#fff','size':(200,200)}, }, } THUMBNAIL_TRANSPARENCY_EXTENSION = 'jpg' I've tried some debugging and everything seems to work quite well and makes sense until the code reaches a line 318 in the background-processor function of easy-thumbnails processors.py: im = colorspace(im, replace_alpha=background, **kwargs) Here the debugger returns straight to the method that was calling background(im, size, background=None, **kwargs). Is there anything wrong with my configuration of square_image in THUMBNAIL_ALIASES? Could it be anything else? -
I want to Automatically find misused Chinese words in web pages, How Can I make it? [on hold]
I want to Automatically find misused Chinese words in web pages, How Can I make it? I can use Django to display the record, But how to check if the words is misused? Besides Crawler, what else I must need to do the job? natural language processing? After I Crawling the text from webpages, what job I should do to process the text? Thank you. Now I have a website maintained by myself, when I see misused words I submit to my website. :) -
Access a value from a list field in django
I have a list field in my django model as follows: profiles = ListField() I am using mongo as storage database with help of django_mongodb_engine. In mongo db shell, If I want to search on a field in a list, like searching 'alice' in ['alice', 'in', 'wonderland'], it can be performed simply by adding in query {'profiles': 'alice'}. Can we perform search like that via django querysets ? When I tried, it gave me an exception "list indices must be integers, not str". Please guide me in this regards. Thanks -
Save OneToOneField field from model in Django
I have a OneToOne relation between 2 models in Django. It looks like this: class QuestionnaireTemplate(TimeStampedModel, QuestionnaireAbstract): # Relations status = models.OneToOneField(QuestionnaireTemplateStatus) is_editable = models.BooleanField(default=True) is_archived = models.BooleanField(default=False) class QuestionnaireTemplateStatus(models.Model): archived_date = models.DateTimeField() The problem is that when I change some information from QuestionnaireTemplate, and call save method, the field status doesn't saves. I know that I have to override save method for QuestionnaireTemplate to do that. But I don't really know how. Can someone help me? PS: Django begginer :) -
Django form in the base template. How to display validation error?
I use Django 1.8.14. I have Search form on every page of my website. I pass Search form to base template through context processor. Each time form sends data to /search/ view. And there is a problem. Django raises ValidationError on form, but it doesn't display anywhere. What is the correct way to display form errors in template, when form passes to base template through context processor and sends data to one view? form.py: class SearchForm(forms.Form): search = forms.CharField(required = True, max_length=255, widget = forms.TextInput({'class':'form-control', 'type':'search','required':''}) ) def clean_search(self): search = self.cleaned_data.get("search") regex = myregex if not re.match(regex, search): print("ValidationError") raise forms.ValidationError(u'Please enter a valid value') return search context processor: from myproject.forms import SearchForm def form_context(request): context_dict = {} context_dict['search_form'] = SearchForm() return(context_dict) my base template: <form method="post" action="/search/"> {% csrf_token %} {{ search_form.non_field_errors }} {{ search_form.errors }} {{ search_form.search }} {{ search_form.search.errors }} <button type="submit" class="btn btn-find">Search</button> </form> my seach view: def search(request, template): if request.method == 'POST': search_form = SearchForm(request.POST) if search_form.is_valid(): domen = search_form.cleaned_data['search'] try: site = SitePage.objects.get(domen=domen) path="/"+site.domen +"/" return HttpResponseRedirect(path) except: site = None else: print search_form.errors return render(request, template, context_dict) -
Why two similar model behaves differently in django
I have two similar models but when render them it behaves differently. My first two models are: class Sitting(models.Model): sit_date = models.DateField(blank=False,unique=True) cut_off_date = models.DateField(null=True, blank=True) ballot_date = models.DateField(null=True, blank=True) class Circular(models.Model): cir_no = models.IntegerField(blank=False) sit_start_date = models.DateField(blank=False) sit_end_date = models.DateField(blank=False) @property def ballot(self): qs = Sitting.objects.filter(sit_date=self.sit_start_date) return qs and in the template: {% for b in c.ballot %} <p>ballot: {{ b.ballot_date }}</p> {% endfor %} It gave correct date. But When I use following two models which are nearly same as above it shows nothing: class NewSitting(models.Model): sit_date = models.DateField(blank=False, unique=True) new_sit_date = models.DateField(null=True, blank=True, unique=True) cut_off_date = models.DateField(null=True, blank=True) ballot_date = models.DateField(null=True, blank=True) def get_new_sit_date(self): return self.sit_date def save(self, *args, **kwargs): if not self.new_sit_date: self.new_sit_date = self.get_new_sit_date() super(NewSitting, self).save(*args, **kwargs) class Circular(models.Model): cir_no = models.IntegerField(blank=False) sit_start_date = models.DateField(blank=False) sit_end_date = models.DateField(blank=False) def newballot(self): qs = NewSitting.objects.filter(new_sit_date=self.sit_start_date) return qs and In the template: {% for b in c.newballot %} <p>ballot: {{ b.ballot_date }}</p> {% endfor %} This template shows nothing. Where I am doing wrong? -
Mailchimp can not access from django admin site
I am using Mailchimp in my project. Everything is work fine, I could create a list and subscribe user to the list and it is showing on the Mailchimp dashboard. But when I try to verify it from my Django admin site http://127.0.0.1:8000//admin/mailchimp/campaign/ (from this link) I am getting the following error. Reverse for 'mailchimp_overview' with arguments '()' and keyword arguments '{'page': 1}' not found. 0 pattern(s) tried: [] I have tried to add this from mailchimp import urls as mailchimp_urls ... urlpatterns += i18n.i18n_patterns( ... url(_(r'^admin/mailchimp'), include(mailchimp_urls)), ... ) But this ends up with the following error ImportError at /admin/mailchimp/campaign/ No module named defaults According to the doc there is no need to add the URL. And I could not figure out where the issue is. Thanks in advance. -
reorder data in database in no particular order
I would like to ask. We have an app called Task and the fields in the model are: id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) name = models.CharField(max_length=120) created_datetime = models.DateTimeField(default=timezone.now) my concern is, in this task, we would like to allow the user the re-order the task the they have made depending on how they want it to be displayed. I am working on the backend part, I wanted to know how to do it. I came up with one idea but I am not sure how good it is. I added a new field: priority = models.CharField(max_length=30) this is the field that will trigger the order in the query "order by". But I do not really know what values I will be putting in there. Should it be something link this id name priority 1 task1 1 2 task2 2 3 task3 3 for instance, this is the initial data the user input to the database. and when he wants to change the order like he wants to move task2 to the first place. should the task2 and task1's priority will be modified like: id name priority 1 task1 2 2 task2 1 3 task3 3 this is the thing … -
Nginx + Systemd/Systemctl + Django not working (502 bad gateway)
I've been at this for hours and yet I cannot figure out why my setup isn't working. If I run the command that's in exec on its own, I can access the page through my browser just fine. But when I try to run it as a service, I get a 502: Bad Gateway. I first tried using Unix sockets, but when that didn't work, I just plugged in the IP and port directly, still no luck. gunicorn.service: [Unit] Description=gunicorn daemon After=network.target [Service] User=username WorkingDirectory=/home/username/naomiselect Environment="PATH=/home/username/naomiselect/naomienv/bin" ExecStart=/home/username/naomiselect/naomienv/bin/gunicorn --workers 3 --bind local_ip:8000 naomiselect.wsgi:application [Install] WantedBy=multi-user.target nginx.conf: user www-data; worker_processes auto; pid /run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime.types; default_type application/octet-stream; ## # SSL Settings ## ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE ssl_prefer_server_ciphers on; ## # Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## gzip on; gzip_disable "msie6"; # gzip_vary on; # gzip_proxied any; # gzip_comp_level 6; # gzip_buffers 16 8k; # gzip_http_version 1.1; # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; ## … -
Django: Search Engine
I am trying to make a search engine of sorts in Django, where the user enters a query via a form and gets an output if the query exists in the database. Here's my code: urls.py: from django.conf.urls import url from django.contrib import admin from Search import views urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^', views.form), url(r'^search/', views.data,name='search'), ] models.py: from __future__ import unicode_literals from abc import ABCMeta from django.db import models # Create your models here. class Album(models.Model): artist = models.CharField(max_length=100) album_title = models.CharField(max_length=100) genre = models.CharField(max_length=100) album_logo = models.CharField(max_length=100) def __str__(self): return self.album_title + "-" + self.artist views.py: from django.http import HttpResponse,Http404 from models import Album from forms import FormQuery from django.shortcuts import render from django.template import loader from . import * def data(request): if request.method=='POST': form=FormQuery(request.POST) data=form.cleaned_data value=data['query'] if form.is_valid(): try: album1 = Album.objects.get(artist__contains=value) return render(request,'Search/form.html',{'album':album1}) except: raise Http404("Does not exist.") else: return render(request,'Search/form.html') forms.py: from django import forms class FormQuery(forms.Form): query=forms.CharField() form.html: <form action="{% url 'search' %}" method="POST">{% csrf_token %} <fieldset> Enter an album:<br> <input type="text" name="query" ><br> <input type="submit" value="Submit for Search >>"> </fieldset> </form> {% if album %} <h1>{{ album }}</h1> {% endif %} However, when I type the query,I see the url change ,but … -
html table truncate text but fit as much as possible
I find some posts in stackoverflow but it doesn't work for me. I need some specific help. This is my board page : When I type long title post, it looks like this : As you can see here, it ruins each table cell's width, as well as text not being truncated.\ What I want to do : If text reaches the end of title field, it should be truncated Anything should not ruin the table format (width..etc) Here is my html code (used in django): {% extends 'chacha_dabang/skeleton/base.html' %} {% block content %} <div class="container inner"> <div class="row"> <div class="col-md-8 col-sm-9 center-block text-center"> <header> <h1> 차차다방 게시판 </h1> <p> 회원들의 게시글을 볼 수 있는 페이지 입니다.</p> </header> </div><!-- /.col --> </div><!-- /.row --> </div><!-- /.container --> <div class="container inner-bottom"> <div class="table-responsive"> <table class="table"> <col width="65%"> <col width="15%"> <col width="13%"> <col width="7%"> <thead> <tr> <th>제 목</th> <th>작성자</th> <th>작성일</th> <th>조회수</th> </tr> </thead> <tbody> {% for post in posts %} <tr> <td class="td-title-area"> <a href="{{ post.get_absolute_url }}" class="td-title"> {{ post.title}} </a></td> <td> {{post.author}} </td> <td> {{post.created_at|date:"SHORT_DATE_FORMAT"}} </td> <td> 11 </td> </tr> {% endfor%} </tbody> </table> </div> <br> <br> {% if is_paginated %} <div class="pagination text-center" style="position:center;"> <span class="page-links"> {% if page_obj.has_previous %} … -
Export button is not visible with django-import-export package
I am trying to use django-import-export module in my admin and here are my settings admin.py from import_export.admin import ImportExportMixin, ImportMixin, ExportActionModelAdmin, ImportExportActionModelAdmin class RegistrationAdmin(ImportExportActionModelAdmin): list_display = ('user', 'activation_key_expired') raw_id_fields = ['user'] search_fields = ('user__username', 'user__first_name', 'user__last_name') admin.site.register(RegistrationProfile, RegistrationAdmin) With the above code, i can able to see an Import button in admin as below But i can't able to see Export option, so what's the problem what am i missing here ? I have seen some ticket about export button permission here https://github.com/django-import-export/django-import-export/issues/38 ? can anyone please let me know what need to be done in order for Export to appear ? -
Django Foreign Key and Forms
I am new to Django and was wondering if I could get some help. I am trying to display a form in my template for a ToolCheckOut that will have two foreign keys that are referencing my two models. I keep receiving this error and have had no luck finding a solution. Error: "coercing to Unicode: need string or buffer, long found" it is giving this error on my template for this line: "{{form.as_p}}" I am using a mysql db that I had previously built for this project. Form: class ToolCheckoutCreateForm(forms.ModelForm): class Meta: model = ToolTransaction fields = [ "ToolID", "Quantity", "PartyID", "CheckOutDate", "CheckInDate", ] Models: class Tool(models.Model): ToolID=models.CharField(max_length=100, primary_key = True, unique=True, null=False) Quantity=models.IntegerField(null=False) Location=models.CharField(max_length=100, null=False) CategoryID=models.IntegerField(null=True) Deleted=models.BooleanField(default=0) objects=models.Manager() class Meta: managed=True db_table='Tool' def __unicode__(self): return self.ToolID def get_absolute_url(self): return reverse("ToolSearch:toolSearchResults", kwargs={"pk": self.ToolID}) class Party(models.Model): PartyID=models.AutoField(primary_key=True) FirstName=models.CharField(max_length=100, null=False) LastName=models.CharField(max_length=100, null=False) PhoneNumber=models.CharField(max_length=25, null=False) Organization=models.CharField(max_length=100, null=True) Deleted=models.BooleanField(default=0) objects=models.Manager() class Meta: managed=True db_table='Party' def __unicode__(self): return self.PartyID def get_absolute_url(self): return reverse("ToolSearch:borrowerUpdate", kwargs={"pk": self.PartyID}) class ToolTransaction(models.Model): CheckOutID=models.AutoField(primary_key=True) ToolID=models.ForeignKey(Tool, on_delete=models.CASCADE) PartyID=models.ForeignKey(Party, on_delete=models.CASCADE) Quantity=models.IntegerField(null=False) CheckOutDate=models.DateField(null=False) CheckInDate=models.DateField(null=True) Deleted=models.BooleanField(default=0) objects=models.Manager() class Meta: managed=True db_table='ToolTransaction' ordering=('CheckOutID',) def __unicode__(self): return str(self.CheckOutID) or u'' def get_absolute_url(self): return reverse("ToolSearch:toolCheckout", kwargs={"pk": self.CheckOutID}) Template: <form method = 'POST' action=''> {% csrf_token %} {{form.as_p}} … -
Django Channels using django shell
I'm currently am trying to use Celery to send sockets with django channels. However I found the same issue there as with using Django's shell, and was hoping if someone could enlighten me. I have it set up so that within views.py, when a user sends a POST request it will call Group("chat").send({'text':'hello'}) The browser then displays an alert. However when I try to do the same thing using Django's shell or one of Celery's tasks: $ python3 manage.py shell $ from channels import Group $ Group("chat").send({'text': 'hello'}) It doesn't do anything, not even returning an error.