Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to return queryset instead of list?
models class Permission(models.Model): name = models.CharField(max_length=250, unique=True) class PermissionDetail(): perm = models.ForeignKey( Permission, on_delete=models.CASCADE, related_name='perm_details') group = models.ForeignKey( 'Group', blank=True, null=True, related_name='group_perms', on_delete=models.CASCADE) class Group(): name = models.CharField(max_length=250) users = models.ManyToManyField(User, blank=True, related_name='groups') permissions = models.ManyToManyField(Permission, blank=True, related_name='permissions') what I did: user_groups = user.groups.all() perm_details = [] for group in user_groups: perm_details.append(group.group_perms.filter(perm=perm)) return perm_details This returns the correct list of data but I want queryset instead of list. How can I return the queryset instead of making list here ? -
when client request to server, there is an error, saying 'Permission denied' from static directory
it seems like Nginx can not access the static files. I checked /var/log/nginx/error.log and got the following messages; after checking this message, I put this code 'chmod -R 755' but it did not work (even 777) of course I did collectstatic and point to static root before this matter happened. I don't know why this happened and how to fix it... I have been struggling with this matter for more than 3 days now 2021/05/12 00:17:07 [error] 12940#12940: *10 open() "/home/admin/github/djangobook/static/admin/css/nav_sidebar.css" failed (13: Permission denied), client: 101.191.5.33, server: 149.28.172.215, request: "GET /static/admin/css/nav_sidebar.css HTTP/1.1", host: "easycoding.live", referrer: "http://easycoding.live/admin/login/?next=/admin/" 2021/05/12 00:17:07 [error] 12940#12940: *2 open() "/home/admin/github/djangobook/static/admin/css/base.css" failed (13: Permission denied), client: 101.191.5.33, server: 149.28.172.215, request: "GET /static/admin/css/base.css HTTP/1.1", host: "easycoding.live", referrer: "http://easycoding.live/admin/login/?next=/admin/" 2021/05/12 00:17:07 [error] 12940#12940: *8 open() "/home/admin/github/djangobook/static/admin/css/login.css" failed (13: Permission denied), client: 101.191.5.33, server: 149.28.172.215, request: "GET /static/admin/css/login.css HTTP/1.1", host: "easycoding.live", referrer: "http://easycoding.live/admin/login/?next=/admin/" 2021/05/12 00:17:07 [error] 12940#12940: *8 open() "/home/admin/github/djangobook/static/admin/js/nav_sidebar.js" failed (13: Permission denied), client: 101.191.5.33, server: 149.28.172.215, request: "GET /static/admin/js/nav_sidebar.js HTTP/1.1", host: "easycoding.live", referrer: "http://easycoding.live/admin/login/?next=/admin/" 2021/05/12 00:17:18 [error] 12940#12940: *1 open() "/home/admin/github/djangobook/static/admin/css/nav_sidebar.css" failed (13: Permission denied), client: 101.191.5.33, server: 149.28.172.215, request: "GET /static/admin/css/nav_sidebar.css HTTP/1.1", host: "easycoding.live", referrer: "http://easycoding.live/admin/" 2021/05/12 00:17:18 [error] 12940#12940: *10 open() "/home/admin/github/djangobook/static/admin/css/dashboard.css" failed (13: Permission denied:```` -
AttributeError at / 'dict' object has no attribute '_mptt_meta'
I try to build blog by using posts and MPTT comments, this will be in the home view www.mysite.com that's mean I cann't pass pk to the url so I tried to get the post objects using for loop comma = Post.objects.all() comm = [] for post in comma: comment = PostCommentIDF.objects.filter(post=post) comm.append({"comme": comment} And my Mptt comment model class PostCommentIDF(MPTTModel): post = models.ForeignKey(Post, on_delete=models.CASCADE, related_name='pos_com') parent = TreeForeignKey('self', on_delete=models.CASCADE, null=True, blank=True, related_name='post_children') author = models.ForeignKey(Account, on_delete=models.CASCADE) content = models.TextField() created_date = models.DateTimeField(auto_now_add=True) status = models.BooleanField(default=True) likes = models.ManyToManyField(Account, blank=True, related_name='pos_com') My Post Model class Post(models.Model): author = models.ForeignKey(Account, on_delete=models.CASCADE) article = models.TextField(null=True, blank=True) photo_article = models.ImageField(max_length=255, upload_to=get_poster_filepath) My mptt coments in the template {% recursetree comment %} <div id="{{ node.id }}" class="my-2 p-2" style="border: 0px solid grey"> <div class="d-flex justify-content-between"> {{ node.publish|naturaltime }} <div class="node-content mt-3">{{ node.content }}</div> </div> {% endrecursetree %} -
Django DRF not returning image field url
I am trying to get the figure field url in get request. However, I am getting error or null value. Question Model class Question(models.Model): """ Base class for all question types. Shared properties placed here. """ quiz = models.ManyToManyField(Quiz, verbose_name=_("Quiz"), blank=True) category = models.ForeignKey(Category, verbose_name=_("Category"), blank=True, null=True, on_delete=models.CASCADE) sub_category = ChainedForeignKey(SubCategory,blank=True,chained_field="category",chained_model_field="category",show_all=False,auto_choose=True,sort=True,null=True) topic = ChainedForeignKey(Topic,blank=True,chained_field="category",chained_model_field="category",show_all=False,auto_choose=True,sort=True,null =True) figure = models.ImageField(upload_to='uploads/%Y/%m/%d', blank=True, null=True, verbose_name=_("Figure")) Serializer.py class QuestionSerializer(serializers.ModelSerializer): image_url = serializers.SerializerMethodField('get_image_url') getanswers = ChoiceSerializer(many=True) figure = serializers.ImageField( max_length=None, use_url=True ) class Meta: fields=( 'id', 'content', 'figure', 'questionmarks', 'getanswers', 'image_url', ) model=Question def get_image_url(self, obj): request = self.context.get("request") return request.build_absolute_uri(obj.figure.url) I keep getting error. Could some please guide me with the right way to achieve this? -
Django: How to test whether a user is a member of a subclass of django auth Group?
I have the following: class Department(Group): hod = models.ForeignKey(User, models.CASCADE, blank=True, null=False) # Other fields and I need to check whether a user is a department member. Do I go: if user.groups.filter(department__pk=department.pk).exists(): # Do something or: if user.groups.filter(pk=department.pk).exists(): # Do something or is there a better way to check this? Thanks -
Page not found error / url is not working with pk
I m working on learning Django with MDN project on Local Library. My two pages are rendering whereas the book detail page is not rendering and giving error page not found. Please advice what if I have missed anything: So far entire project is on MDN documents. catalog/urls.py from django.urls import path from catalog import views app_name = 'catalog' urlpatterns = [ path('', views.index, name='index'), path('books/', views.BookListView.as_view(), name='books'), path('book/<int:pk>', views.BookDetailView.as_view(), name='book-detail'), ] catalog/templates/catalog/book_detail.html {% extends 'catalog/base.html' %} {% block content %} <h1>Title: {{ book.title }}</h1> <p><strong>Author:</strong> <a href="{{ book.author.get_absolute_url }}">{{ book.author }}</a></p> <p><strong>Summary:</strong> {{ book.summary }}</p> <p><strong>ISBN:</strong> {{ book.isbn }}</p> <p><strong>Language:</strong> {{ book.language }}</p> <p><strong>Genre:</strong> {{ book.genre.all|join:", " }}</p> <div style="margin-left:20px;margin-top:20px"> <h4>Copies</h4> {% for copy in book.bookinstance_set.all %} <hr> <p class="{% if copy.status == 'a' %}text-success{% elif copy.status == 'd' %}text-danger{% else %}text-warning{% endif %}">{{ copy.get_status_display }}</p> {% if copy.status != 'a' %}<p><strong>Due to be returned:</strong> {{copy.due_back}}</p>{% endif %} <p><strong>Imprint:</strong> {{copy.imprint}}</p> <p class="text-muted"><strong>Id:</strong> {{copy.id}}</p> {% endfor %} </div> {% endblock %} catalog/templates/catalog/base.html {% load static %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" href="{% static 'catalog/style.css' %}"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-wEmeIV1mKuiNpC+IOBjI7aAzPcEZeedi5yW5f2yOq55WWLwNGmvvx4Um1vskeMj0" crossorigin="anonymous"/> {% block title %} <title></title> {% … -
TypeError object is not iterable in Django
I am creating a movie site using Django. I have created a Genre model in it and displayed it in the template. Now i want those each genre objects to redirect to some other page. For example i have created 45 genre types and displayed in the template. Now what i want to do is, redirect user to for example Action genre list when clicked on Genre Action in the template. For that i used for loop in template but when clicked in any of the genre objects it throws TypeError at /home/genre/5/ 'Genre' object is not iterable. What is the problem here? Any suggestions will be great. my urls.py: urlapatterns = [path('', views.home, name='home'), path('genre/<int:pk>, views.genreView, name='home')] views.py: def genreView(request, pk): genres = get_object_or_404(Genre, id=pk) context = { 'genres': genres } return render(request, 'genre.html', context) def home(request): genres = Genre.objects.all() context = { 'genres': genres } return render(request, 'index.html', context) home.html: {% for genre in genres %} <a href="{% url 'genre' genre.id %}" class="text-yellow-400 hover:text-white p-2 text-xs">{{genre.title}}</a> {% endfor %} models.py: class Genre(models.Model): title = models.CharField(max_length=500) def __str__(self): return self.title -
Customize the Django ContentTypes and AdminLog and Migration model
I am working on a Django project and it requires 3 different database servers with different engines like MySql, PostgreSQL and SQLite. SQLite has all the client side setting table, tables with not shared data [app has a feature to not upload some data to the server] and configuration tables and it is on the client machine through a tweaked C# app to create a django server environment and show the django site in a browser control like a native application. PostgreSQL has tables that can be accessed by different clients on the network and has different tables with values of shared data. They maintain integrity with SQLite data through ContentType. Django provides the contentType table that is created in both SQLite and PostgreSQL. Due to heavy use of other database managing tables we require them to be in a MySQL database on a separate server. So it would be great to have django_content_types, django_admin_log and django_migration in that MySQL server. ContentTypes table is also used a lot and it is difficult to maintain contentTypes form two different database tables so we require it to be in one separate one with values form both the databases. And when one goes … -
Is there a way that django access the cookies stored by the browsers for authentication?
I have developed an internal website for my org ,which used some authentication at browser level (like login),they will authenticate on the start of the day and they want that authentication to even visit my website .I am accessing another service in the back-end which requires the same cookies which was stored by the browser when they authenticate .Is there a way i can get that cookies from the browser storage? -
Send image via post request to ImageField
I have a model with API for an ImageField. I need to send image fetched via post method on the template and send it via post request to the API created. The image fetched has a type InMemoryUploadedFile, if I try to send it directly, I get 406 because of failed serializer validation. So I tried making a PIL object out of it and tried sending. I checked the JS counterpart of the code and it just takes the file from the input field and sends it directly to the same field and it works. Is there a way I can just send an image file object via post request to fail serializer validation. category_thumbnail = request.FILES.get('category_thumbnail') category_thumbnail = Image.open(category_thumbnail) data = { 'category_thumbnail': category_thumbnail } This would give me 406. I also tried converting image string to a base64 byte object. category_thumbnail = request.FILES.get('category_thumbnail') category_thumbnail = Image.open(category_thumbnail) with io.BytesIO() as output: category_thumbnail.save(output, format="GIF") contents = output.getvalue() category_thumbnail = base64.b64decode(contents) data = { 'category_thumbnail': category_thumbnail } but this would give me 406 too. I wonder if there's a way I can just send the image file object taken from InMemoryUploadedFile. Also tried category_thumbnail = request.FILES.get('category_thumbnail').file -
Django-Email, sending multiple email depends on Email ID
Anyone know how to solved my issue, Im working with DJango-email with multiple recipient. Sending email in multiple recipient accounts from my DB are working, but now I want to send email and the email:body are depending on the Data ID. This are the email list, Scenario: Plate_No: 123123 will be send to example_email1@gmail.com only and ABV112 will be send again to example_email2@gmail.com and so on. Only the Plate_no assign in email will send, can someone help me to work my problem. Thank you! Here are my auto send email script: class HomeView(ListView): cstatus = VR.objects.filter(Deadline__date = datetime.datetime.today(), sent_email="No") print(cstatus) recipient_list = [] for recipient in cstatus: recipient_list.append(recipient.email) print(recipient_list) plate = "" for carreg in cstatus: print(carreg.plate_no) plate = carreg.plate_no if plate != "": subject = 'FMS Automated Email' html_message = render_to_string('vr/pms_email.html', {'content':cstatus}) plain_message = strip_tags(html_message) from_email = 'FMS <fms@gmail.com>' mail.send_mail(subject, plain_message, from_email, recipient_list, html_message=html_message, fail_silently=False) cstatus.update(sent_email="Yes") model = VR context_object_name = 'list' template_name = 'vr/list.html' -
Django display survey questioner with different choices in template
I am working on a survey app where users that have administrator role can login to the admin dasboard and create surveys. A survey can have multiple questioniors. When creating a survey the admin users can add either checkbox choice, radio choice or a text box option to a question. At the moment these functionality is working fine, what i need help with is how to display the survey questions to the surveyor page. How can i display all the questioners with option such as checkbox, textbox etc. The current template can only display the questions with radio choices. class Survey(models.Model): title = models.CharField(max_length=200) # creator = models.ForeignKey(User, on_delete=models.CASCADE) created_at = models.DateTimeField(default=timezone.now) archive = models.CharField(max_length=200, default='') def __str__(self): return self.title class Question(models.Model): survey = models.ForeignKey(Survey, on_delete=models.CASCADE) enter_question = models.CharField(max_length=900) def __str__(self): return self.enter_question class Choice(models.Model): question = models.ForeignKey(Question, on_delete=models.CASCADE) choice = models.CharField(max_length=100) choice_text = models.CharField(max_length=100) choice_check = models.CharField(max_length=100, null= True) <div class = "jumbotron container centerdv header-top"> <h2>{{survey.title}}</h2> </div> <div class="d-flex flex-column"> <form method = "post" action =#> <input type = "hidden" name = "survey_id" value = {{survey.id}}> {% csrf_token %} {% for question in questions %} <div class="p-2"> <h4 class="header"> Question {{ forloop.counter }}: {{ question.enter_question }} </h4> </div> … -
mapping request.data into a onetoone field
I have a JSON request data as follows and I want to process that using Django serializer and views in order to create the record in the database using a POST request. { "username":"user1", "first_name":"name1", "email":"name1@gmail.com", "phone": "123456", "app_id": "435673339303abc" } And following are my Django database models and serializer where a custom user model is created which has a onetoone django user model: models.py from django.contrib.auth.models import User from django.db import models class CustomUserModel(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) phone = models.CharField(max_length=20, blank=True) app_id = models.CharField(max_length=20, blank=True) serializers.py class UserSerializer(serializers.ModelSerializer): class Meta: model = User fields = ('username', 'first_name', 'email') class CustomUserSerializer(serializers.ModelSerializer): user = UserSerializer(required=True) class Meta: model = CustomUserModel fields = ('user', 'phone', 'app_id') def create(self, validated_data): user_data = validated_data.pop('user') user = UserSerializer.create(UserSerializer(), validated_data=user_data) customuser, created = CustomUserModel.objects.update_or_create(user=user, defaults={ 'phone': validated_data.pop('phone'), 'app_id': validated_data.pop('app_id')}) return customuser views.py class usersApi(generics.ListAPIView): serializer_class = CustomUserSerializer def get_queryset(self): queryset = CustomUserModel.objects.all() return queryset def post(self, request, format=None): serializer = CustomUserSerializer(data=request.data) if serializer.is_valid(raise_exception=ValueError): serializer.create(validated_data=request.data) return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.error_messages, status=status.HTTP_400_BAD_REQUEST) But with this serializer and views, I have to pass a nested json data as follows with user object which I don't want to. { "user": { "username":"user1", "first_name":"name1", "email":"name1@gmail.com" }, "phone": "123456", "app_id": "435673339303abc" … -
In Django I want to fetch the selected file name file is in my media folder so I want to fetch it and display it in html that the file is selected
This is my html code for update the form I have the uploaded file through a html form and the pdf file is getting stored in my media folder and the file name in database, so like the text fields I also want to retrieve the selected file from the media folder the value ="{{i.cv}}" is not working like I did it in text fields so basically I have two html one is for filling up where there is also file field am uploading pdf files in it and it is storing in media folder another html for updating the data in there the upload cv does not select any file what's the solution for this. this is my html <div class="row form-group"> <div class="col-md-12 mb-3 mb-md-0"> <label class="text-black">Upload CV</label></br> <input type="file" name="cv" id="cv1" value ="{{i.cv}}"> </div> </div> here is models.py class ApplyForm(models.Model): cv = models.FileField(upload_to='') this is views.py def update(request, id): i.cv = request.FILES['cv'] I just want the file to be selected during edit I am uploading pdf files -
How I can get the object from the for loop in Django
I try to get object from foor loop and pass it to context -> template but when I try to do this it return null values for example here for post in comma: comment = PostCommentIDF.objects.filter(post=post) #here I try to get the object out side post_with_comments.append({post, comment}) print(comment.all()) So in this example I can't pass it to template because it return null but here it works when I try to print the values inside the foor loop for post in comma: comment = PostCommentIDF.objects.filter(post=post) post_with_comments.append({post, comment}) print(comment.all()) So My qustion here how I can pass the comment to template and return actual values not null values -
Python pipeline error when deploying to EC2 setuptools_rust
Hello I'm having this problem when trying to deploy a django application to aws, the app runs perfectly locally but when trying to deploy to aws this error shows up. like this I tried to install that manually, but it doesn't work that way. -
Documenting a file download on RESTApi
I have the following view which returns a file, the thing is that I don't know how to write a documentation for this route. This doesn't return JSON, it returns a file based on the Content-type that the client has asked for. def get(self, *args): """ * ``:param request:`` GET request to send with ``Authorization: Bearer token_id``. * ``:return:`` Authenticated Seeker CV file """ seeker_cv_file = CV.objects.get(seeker=self.get_queryset()).cv_file return HttpResponse(seeker_cv_file, content_type=self.request.content_type) I don't have any idea on how to write a conventional documentation block for this route. Any suggestion? I am using drf-spectacular by the way. -
Python/DJANGO: How to modify existing variable and also import new variables using import *
I have a file test.py with list_sample = [1,2,4] Now, I want to append to the list from another file eg: test2.py list_sample =+ [10,11] # also I have many other things in this script a=10 c=10+a and modify test.py as list_sample = [1,2,4] # I want to import all the variables from test2.py but also append the list_sample # I cant do that directly in this file. Because this is like blueprint from .test2 import * print(a+30) print(list_sample) But this gives an error list_sample not defined The only way I can do this change test2.py to list_sample = [1,2,4,10,11] # also I have many other things in this script a=10 c=10+a One more option i have is change test2.py to from .test import list_sample list_sample += [10,11] # also I have many other things in this script a=10 c=10+a but this will lead to circular imports Conclusion This is not possible so then i decided to just go like this. Add some segregation in the test2.py # variables from master file # copy them from the test.py list_sample = [1,2,3] # changes to variables from master file list_sample =+ [10,11] # new variables a=10 c=10+a Reason I want this … -
django.db.utils.OperationalError: FATAL: sorry, too many clients already
I am running a Django app on Django's development server with PostgreSQL as the backend database. I got this error: django.db.utils.OperationalError: FATAL: sorry, too many clients already when I was doing a load testing using Locust. My Locust script runs the test with 100 concurrent clients: env.runner.start(100, spawn_rate=100, wait=True) I have seen several answers on SO, such as: Getting OperationalError: FATAL: sorry, too many clients already using psycopg2 Getting "FATAL: sorry, too many clients already" when the max_connections number is not reached Django+Postgres FATAL: sorry, too many clients already From those threads, I think I understand the cause of the error, but I am still very confused. How does it scale in real life if PostgreSQL cannot handle even 100 concurrent clients? Does it have anything to do with the fact that I am using a development server? Will it help if I use Gunicorn? If some connection clean-up is needed, is it something that I should implement in the Locust script? I am quite new in this area, so I apologize if the answers to those questions are obvious. -
Betfair - Result After Match Completion without placing bet
We are fatching odds from betfair API. How can we see result of that game/odds without placing bet on betfair ? -
Django REST framework change JSON structure
I am working on a Django project, the data that I have now is something like this: [ { "sid": "A1", "annofk": [ { "id": 8, "chrs": "chr1", "seq_start": 18262640, "seq_end": 18262660, }, { "id": 9, "chrs": "chr1", "seq_start": 18262640, "seq_end": 18262660, }, { "id": 10, "chrs": "chr1", "seq_start": 18262640, "seq_end": 18262660, } ] }, { "sid": "A2", "annofk": [ { "id": 5, "chrs": "chr1", "seq_start": 24613130, "seq_end": 24613155, }, { "id": 11, "chrs": "chr1", "seq_start": 24613130, "seq_end": 24613154, } ] } ] I really want to change the structure into this: [ { "sid": "A1", "annofk": { "id": 8, "chrs": "chr1", "seq_start": 18262640, "seq_end": 18262660, } }, { "sid": "A1", "annofk": { "id": 9, "chrs": "chr1", "seq_start": 18262640, "seq_end": 18262660, } }, { "sid": "A1", "annofk": { "id": 10, "chrs": "chr1", "seq_start": 18262640, "seq_end": 18262660, } }, { "sid": "A2", "annofk": { "id": 5, "chrs": "chr1", "seq_start": 24613130, "seq_end": 24613155, } }, { "sid": "A2", "annofk": { "id": 11, "chrs": "chr1", "seq_start": 24613130, "seq_end": 24613154, } } ] These data are from two tables (models). These data are from a reverse look up results. Two Serializers is here: class AnnotationSerializer(serializers.ModelSerializer): class Meta: model = annotation fields = "__all__" class … -
How to calculate the date of a Blog post in hours days months and years?
I have a Blog Post and would like to calculate the day, months and years elapsed? class Post(models.Model): title = models.CharField(max_length=200, unique=True) slug = models.SlugField(max_length=200, unique=True) author = models.ForeignKey(User, on_delete= models.CASCADE,related_name='blog_posts') created_on = models.DateTimeField(auto_now_add=True) I would like it in a format like 1 year ago, 2 days ago, 2 hrs ago. -
How do I update data on SQLite Database using HTML
I'm trying to allow users to update the information that they have provided by clicking the edit icon on my html webpage, but I am unsure on how to start. Below are the codes used to add new data and retrieve the newly added data: def newclaim(request): context = initialize_context(request) user = context['user'] if request.method == 'POST': name = request.POST['name_field'] email = request.POST['email_field'] claim = request.POST['claim_field'] claimtype = request.POST.get('claimtype') description = request.POST['description_field'] receipt = request.POST.get('receipt_field') cheque = request.POST.get('Cheque') ins = SaveClaimForm(name=name, email=email, claim=claim, claimtype=claimtype, description=description, receipt=receipt, cheque=cheque) ins.save() print("The Data has been written") return render(request, 'Login/newclaim.html/', context) viewclaims def viewclaims(request): context = initialize_context(request) user = context['user'] if user.get('email', None): claims = SaveClaimForm.objects.filter(email=user.get('email', None)) return render(request, 'Login/existingclaims.html', {'claims':claims, 'user':user}) SaveClaimForm Models class SaveClaimForm(models.Model): name = models.CharField(max_length=200) email = models.EmailField() claim = models.DecimalField(decimal_places=2, max_digits= 6) claimtype = models.CharField(max_length=200) description = models.TextField(max_length= 500) receipt = models.FileField() cheque = models.CharField(max_length=200) -
Run a django update but call the save method
Is there a way to do the following: Asset.objects.filter(pk=asset.pk).update(**item) And also call the .save() method? I think I've read somewhere that you can run an update on the actual instance and not go through the objects manager. How would that be done? Currently I'm doing the following, which is quite repetitive and inefficient: a = Asset.objects.filter(pk=asset.pk).update(**item) a.save() -
pip freeze is not providing correct package versions
I had a remote developer help me with a Django Channels project, and what he did works well. Now I am trying to reproduce his work on my production server, and am stuck... (Unfortunately, the remote developer is not available to ask as he seems to have fallen off planet earth) When I do pip freeze on his project I get: (Among many other items that all match my pip freeze exactly) channels==3.0.2 channels-redis==2.4.2 when I try to install these same packages on my project I get the error: File "./site/asgi.py", line 31, in <module> url(r"^stream/(?P<device_id>[\d\-]+)/$", StreamConsumer.as_asgi()), AttributeError: type object 'StreamConsumer' has no attribute 'as_asgi' Which is referring to my asgi.py file: application = ProtocolTypeRouter({ # Django's ASGI application to handle traditional HTTP requests "http": django_asgi_app, # WebSocket chat handler "websocket": AuthMiddlewareStack( URLRouter([ url(r"^stream/(?P<device_id>[\d\-]+)/$", StreamConsumer.as_asgi()), url(r"^status/(?P<device_id>[\d\-]+)/$", StatusConsumer.as_asgi()) ]) ), }) After some searching on this error, I came to the conclusion that this is due to older channels-redis So I did pip install channels-redis==3.2.0 Now the error is gone, great. But now the websockets keep disconnecting and crashing due to these 2 errors: <WebSocketProtocol client=['127.0.0.1', 59462] path=b'/ws/stream/streaming'> took too long to shut down and was killed. and channels_redis/core.py", line 667, …