r/djangolearning Jun 06 '25

Welcome to r/djangolearning

2 Upvotes

This post contains content not supported on old Reddit. Click here to view the full post


r/djangolearning 13h ago

I Need Help - Troubleshooting Tutorial Part 2: Implement a Chat Server

6 Upvotes

I'm following along the django channels tutorial and I'm running into a timeout error that I don't understand. I have everything setup as shown in the tutorial and it works for 5 seconds. If I open a page to a chatroom and constantly send a message every 5 seconds or less, the connection will remain connected. I can open a second window and send messages from the first window to the second, or vise-versa. However, if I stop sending messages for more than 5 seconds, there is a timeout error that occurs and I get an error message in the server terminal.

I have been looking online to see if I can find the issue but I'm at a bit of a loss what to look for.

The first error discusses Redis. I think Redis is just a easy way to create a database in memory for rapid access. If this is correct, I don't think Redis is the problem.

I don't think the problem is the result of my browser as I've tested with Chromium and Firefox with the same timeout results.

There are some error messages coming from django as well. I didn't see anything in the files setting a timeout parameter of any sort, let-alone one at 5 seconds.

I was modifying the tutorial code to learn a bit more and encountered this issue. I tried with a new server by simply copying and pasting the tutorial code directly to see if that would fix the problem but it didn't. (I can connect and send messages but a timeout error occurs after 5 seconds of idle time.) The tutorial doesn't talk about a timeout parameter being set. Technically speaking, the tutorial code does work and allows messages to be sent between 2 different windows so I think that it is probably working correctly. I would share the code, but I don't know what part to share.

Are there any configuration/parameter files where a timeout value is set?

Here is the error code that I receive:

HTTP GET /chat/lobby/ 200 [0.01, 127.0.0.1:42272]
WebSocket HANDSHAKING /ws/chat/lobby/ [127.0.0.1:42288]
WebSocket CONNECT /ws/chat/lobby/ [127.0.0.1:42288]
Exception inside application: Timeout reading from localhost:6379
Traceback (most recent call last):
  File "/proj_root/.venv/lib/python3.12/site-packages/redis/asyncio/connection.py", line 783, in read_response
    response = await self._parser.read_response(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/proj_root/.venv/lib/python3.12/site-packages/redis/_parsers/resp3.py", line 185, in read_response
    response = await self._read_response(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/proj_root/.venv/lib/python3.12/site-packages/redis/_parsers/resp3.py", line 197, in _read_response
    raw = await self._readline()
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/proj_root/.venv/lib/python3.12/site-packages/redis/_parsers/base.py", line 578, in _readline
    data = await self._stream.readline()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/streams.py", line 568, in readline
    line = await self.readuntil(sep)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/streams.py", line 660, in readuntil
    await self._wait_for_data('readuntil')
  File "/usr/lib/python3.12/asyncio/streams.py", line 545, in _wait_for_data
    await self._waiter
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/proj_root/.venv/lib/python3.12/site-packages/redis/asyncio/connection.py", line 782, in read_response
    async with async_timeout(read_timeout):
  File "/usr/lib/python3.12/asyncio/timeouts.py", line 115, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/proj_root/.venv/lib/python3.12/site-packages/django/contrib/staticfiles/handlers.py", line 101, in __call__
    return await self.application(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/proj_root/.venv/lib/python3.12/site-packages/channels/routing.py", line 48, in __call__
    return await application(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/proj_root/.venv/lib/python3.12/site-packages/channels/security/websocket.py", line 37, in __call__
    return await self.application(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/proj_root/.venv/lib/python3.12/site-packages/channels/sessions.py", line 44, in __call__
    return await self.inner(dict(scope, cookies=cookies), receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/proj_root/.venv/lib/python3.12/site-packages/channels/sessions.py", line 261, in __call__
    return await self.inner(wrapper.scope, receive, wrapper.send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/proj_root/.venv/lib/python3.12/site-packages/channels/auth.py", line 185, in __call__
    return await super().__call__(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/proj_root/.venv/lib/python3.12/site-packages/channels/middleware.py", line 24, in __call__
    return await self.inner(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/proj_root/.venv/lib/python3.12/site-packages/channels/routing.py", line 118, in __call__
    return await application(
           ^^^^^^^^^^^^^^^^^^
  File "/proj_root/.venv/lib/python3.12/site-packages/channels/consumer.py", line 95, in app
    return await consumer(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/proj_root/.venv/lib/python3.12/site-packages/channels/consumer.py", line 58, in __call__
    await await_many_dispatch(
  File "/proj_root/.venv/lib/python3.12/site-packages/channels/utils.py", line 57, in await_many_dispatch
    await task
redis.exceptions.TimeoutError: Timeout reading from localhost:6379
WebSocket DISCONNECT /ws/chat/lobby/ [127.0.0.1:42288]

Edit: I found this github issue that has the same error message. I'm not seeing a fix though.


r/djangolearning 18h ago

Discussion / Meta Building a Multi-tenant App with Django

Thumbnail testdriven.io
3 Upvotes

r/djangolearning 21h ago

I Made This Installing django-email-learning

2 Upvotes

In this video I demonstrate how to install django-email-learning, an email based learning platform as a django app allowing you to create email based courses.
https://youtu.be/6JvtevfAniI?si=pn9n7T2NFv484r-l


r/djangolearning 1d ago

Tutorial I'm Starting a Daily Django Errors Series – Follow Along! ⭐

Thumbnail
4 Upvotes

I'm starting a new Django series where I'll post one common Django error every day and walk through how to fix it with a simple, beginner-friendly explanation.

Whether you're just getting started or you've been building with Django for a while, I hope these posts help you debug your projects a little faster.

Feel free to follow along, ask questions, and even suggest errors you'd like me to cover next. Happy coding! 🚀


r/djangolearning 2d ago

Resource / App I want to learn django

14 Upvotes

I have just learned react and build some basic apps, now I want to go into the backend and so I choose python and have some background with it.


r/djangolearning 7d ago

Discussion / Meta What’s a Django feature that felt like a absolute "cheat code" when you finally discovered it?

37 Upvotes

Everyone learns the standard ORM queries, basic class-based views, and how to map URLs early on. But Django is *huge*, and there are so many built-in utilities buried in the docs that completely eliminate the need for third-party packages or complex custom code.

For example, when I finally discovered `F()` **expressions**, it blew my mind. Being able to update a database field based on its current value directly in the DB (like `F('shares') + 1`) without pulling the object into memory and risking race conditions felt amazing.

Another one is utilizing `select_related` **and** `prefetch_related` to instantly drop an app from 150 database queries down to 2.

What’s that one underrated Django feature, decorator, field option, or management utility you stumbled upon that made you think, *"Why wasn't I using this the whole time?"*


r/djangolearning 8d ago

Tutorial I recently implemented multi-tenancy in Django

Thumbnail
3 Upvotes

r/djangolearning 8d ago

I Need Help - Homework Spent 2 months building my Django project and got stuck on authentication. Can someone guide me?

10 Upvotes

Hi everyone,

I have been working on a Django project for the past 2 months as part of my school project. I built most of the application myself after spending time learning the framework instead of relying entirely on AI. Now I'm trying to build the login and authentication system, and I've hit a wall.

I've started using AI more for this part because I don't fully understand Django authentication yet, but I don't want AI to build the entire project for me. I want to understand how it works so I can finish it myself.

I've already created:

  • Custom User model
  • Signup form
  • Login form

However, I'm struggling to connect everything correctly and understand the authentication flow.

If anyone is willing to guide me or point out what I'm doing wrong, I'd really appreciate it. I'm happy to share my code and learn from my mistakes rather than just copy a solution.

Thank you!

Here is the repository
https://github.com/abdullah-Dev-12125-code/Shop-IT-SAAS-


r/djangolearning 8d ago

Resource / App Show me your Django projects, I’ll review them

Thumbnail
2 Upvotes

r/djangolearning 14d ago

I Made This A set of Django skills for Claude Code so my agent stops writing ai slop

Post image
7 Upvotes

r/djangolearning 14d ago

I Need Help - API / DRF Feeling imposter syndrome after "Django for APIs"—is relying on Concrete Views (ListCreateAPIView) bad practice?

Post image
98 Upvotes

Hey everyone,

I just finished Django for APIs and I'm starting my own projects to escape tutorial hell.

The book exclusively taught DRF's concrete views (⁠ListCreateAPIView⁠, etc.). I realized I've never actually written a raw ⁠APIView⁠ or manually used ⁠Mixins⁠.

Is it bad that I only know the "top-down" way? Will I hit a wall in the real world, or are concrete views actually what people use in production?

Thanks!


r/djangolearning 14d ago

I Need Help - API / DRF Feeling imposter syndrome after "Django for APIs"—is relying on Concrete Views (ListCreateAPIView) bad practice?

Post image
32 Upvotes

Hey everyone,

I just finished Django for APIs and I'm starting my own projects to escape tutorial hell.

The book exclusively taught DRF's concrete views (⁠ListCreateAPIView⁠, etc.). I realized I've never actually written a raw ⁠APIView⁠ or manually used ⁠Mixins⁠.

Is it bad that I only know the "top-down" way? Will I hit a wall in the real world, or are concrete views actually what people use in production?

Thanks!


r/djangolearning 14d ago

I Need Help - Question Some good project ideas

Thumbnail
1 Upvotes

r/djangolearning 18d ago

I Need Help - Getting Started Is django dead ? Really?

Post image
0 Upvotes

r/djangolearning 20d ago

I Need Help - Question Which backend language to choose after Html, CSS, JS and react.

Thumbnail
1 Upvotes

r/djangolearning 22d ago

I Need Help - Question Hi wanna connect and grow together?

Thumbnail
5 Upvotes

I am currently learning backend, particularly Django, FastAPI, etc.. Are you into programming, web development and things like that? Are you a learner too? If so, let's connect. I would love to help and be helped, motivate each other in the process, and help when we get stuck here and then.

And of you are thinking about building projects, let's connect too. I would love to collaborate and help, just for experience and nothing more 🙌.


r/djangolearning 22d ago

I Need Help - Getting Started Need career advice: Django first or APIs/FastAPI first?

7 Upvotes

​

Hi everyone,

I'm a B.Tech CSE student and I've recently finished learning:

\- Python

\- Flask

\- SQLite

\- Authentication (login/register, password hashing, sessions)

\- Flask-WTF

My goal is to become a Python Backend Developer and also do freelancing in the future.

Right now I'm confused about what to learn next.

Some people (including AI assistants like Gemini, Claude, and Grok) suggested learning FastAPI first because it's modern and in demand.

Others recommended learning Django first because it's a complete framework and great for backend jobs and client projects.

I'm currently thinking about this roadmap:

Flask → REST API concepts → Flask APIs → Django → Django REST Framework → FastAPI

Do you think this is a good path, or should I skip Django for now and learn FastAPI first?

I'd really appreciate advice from people who are already working as Python backend developers or freelancers.

Thanks!


r/djangolearning 25d ago

I Need Help - Getting Started How to learn Django

11 Upvotes

its been a month im learning python from freecodecamp and w3schools documentations, also follwed the famous Asabeneh / 30-Days-Of-Python on github (skipped the flask part), now i wanna learn django not just the framework but the whole backend engineering. i have good hands on mysql and frontend-html, css, js

but here's my problem where to start like i just cant find right tut, im not someone who can understand everything by documentations so please anyone recommend me something useful like where tf i should strt


r/djangolearning 25d ago

I Made This Would appreciate feedback on my Django Channels chat app

Thumbnail
2 Upvotes

r/djangolearning 26d ago

I Need Help - Getting Started Please help. From . import views not working

1 Upvotes

Hi. I hope you are having a great day so far. I am a django beginner and I was trying to learn django using the official tutorial and the youtube course by BugBytes. The problem is, I keep on getting stuck on the first page of the tutorial. I have tried 3 times with 3 different folders and nothing seems to work. Could you please help me out?

Here's the code:

Note: The file is urls.py inside the app, just like the tutorial specified. In fact, this is just copy pasted from the tutorial.from django.urls import path


from . import views


urlpatterns = [
    path("", views.index, name="index"),
]

I keep on getting the following error:

from . import views

ImportError: attempted relative import with no known parent package

Here's a screenshot of my folder structure.

My main folder is named Django, please do not confuse it with something else

What do I do? I have tried replacing . with the main file name (polls). It hasn't worked either. I also made sure to download Django v6.0. Still didn't work. I would appreciate any advice on how to solve this. Thank you for your time. Have a nice day!

--------------------------------------------------------------------

Here's some extra info just in case:

from django.shortcuts import render


from django.http import HttpResponse



def
 index(request):
    return HttpResponse("Hello, world. You're at the polls index.")

Note: This file is in the views.py file inside the app. It has also been copy pasted from the website. No errors are being flagged in it.

The page for the tutorial is this one: https://docs.djangoproject.com/en/6.0/intro/tutorial01/#write-your-first-view

If you scroll down to the section 'Write your first view', you shall find the exact code that I have used.


r/djangolearning 28d ago

I Need Help - Getting Started Django beginner

3 Upvotes

I'm a completely fresh Django learner. Its been 3 week since i started. Began with python basics, html and css amd now django. I understood the concept of vurws, models, forms, etc. But I still dont get what all to call...? I started doing a project on event management system webpage. Tbh, chatgpt did most of the work and now I'm feeling lost. Idk where to start... how to start...please guide me


r/djangolearning 29d ago

Resource / App Revel: Django-powered, full-fledged event management and ticketing platform now ships a self hosting wizard (MIT License)

Thumbnail
3 Upvotes

r/djangolearning Jun 22 '26

Resource / App SaaS Pegasus—the original Django boilerplate—now has an open source edition

Thumbnail
3 Upvotes

r/djangolearning Jun 19 '26

I Need Help - Getting Started Django Enterprise RBAC: Groups vs User Profiles for a Multi-Branch Microfinance System

Thumbnail
1 Upvotes