Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Display logs generated by class in flask page in real time

I want to display python logs generated when a class is getting executed by taking input from page.i want to display the logs generated as the class is executing in real time in flask page.but the class is getting executed only then the next page with logs is displayed.
Any idea how can I display logs in flask page as the class is executing ..

/r/flask
https://redd.it/1hid1vj
Look for some suggestions

/r/django
https://redd.it/1hihdnp
Can someone explain what sessions are, and why am I facing so much of a problem with my API permissions?

The problem I am facing is that I am not able to access my newly built APIs that require the [IsAuthenticated\] permissions to fetch the data in my Svelte frontend, whereas I am able to perform all the [IsAuthenticated\] API functions on the django restframework UI while testing my APIs. For example, whenever I login using my DRF UI, this is the output I get:
User: Turf Nation

Turf ID: 1, Date: 2024-12-18

[20/Dec/2024 16:46:42] "GET /enterprise/slot-status/?turf_id=1&date=2024-12-18 HTTP/1.1" 200 16716

and now whenever I do the same process using the Svelte frontend, I get this:

User: AnonymousUser

Turf ID: 1, Date: 2024-12-19

[20/Dec/2024 16:47:34] "GET /enterprise/slot-status/?turf_id=1&date=2024-12-19 HTTP/1.1" 200 4460

As you can see the user is being recognised using the DRF UI while not for the frontend. I asked chatGPT about this, and it said this is all related to sessions and cookies, and ISTG, I have never really used those before. The frontend logic is not wrong either because I can access the GET POST functions when they are [AllowAny\].

Can anyone help with this?

/r/django
https://redd.it/1hiicrb
Looking for a Django Collaborator(s). Why not building something together??

Hi all!

This is my first time posting here, so if this kind of request isn’t the norm, please be kind.

I’m a second-year CS student (female) learning Django on my own alongside a course I’ve already finished. I’m currently working on a project with deadline approaching (27th December, yikes!). The project has real-world potential, and if it’s good enough, I’ll get to present it to an employee or even secure school funding to develop it further.

I’d love to work on this project together with someone who’s interested in Django. If it turns into something bigger, we can both benefit from it— adding it to our portfolios and showcasing it as a real-world project.

If you’re interested in collaborating and also if u want to connect as coding buddies (Learning alone sometimes gets so lonely) dm me!

/r/djangolearning
https://redd.it/1hhyye3
Built my own link customization tool because paying $25/month wasn't my jam

Hey folks! I built shrlnk.icu, a free tool that lets you create and customize short links.

What My Project Does: You can tweak pretty much everything - from the actual short link to all the OG tags (image, title, description). Plus, you get to see live previews of how your link will look on WhatsApp, Facebook, and LinkedIn. Type customization is coming soon too!

Target Audience: This is mainly for developers and creators who need a simple link customization tool for personal projects or small-scale use. While it's running on SQLite (not the best for production), it's perfect for side projects or if you just want to try out link customization without breaking the bank.

Comparison: Most link customization services out there either charge around $25/month or miss key features. shrlnk.icu gives you the essential customization options for free. While it might not have all the bells and whistles of paid services (like analytics or team collaboration), it nails the basics of link and preview customization without any cost.

Tech Stack:

Flask + SQLite DB (keeping it simple!)
Gunicorn & Nginx for serving
Running on a free EC2 instance
Domain from Namecheap ($2 - not too shabby)

Want to try it out? Check it

/r/Python
https://redd.it/1hij1l8
I need some websites with their sourcecode

Hi ! I teach web development using python (flask)
And i need some websites online that are built using flask for my students to learn by example.
Problem is i cant find a website like that with its source code available to public at a github repo.
I'll be happy if you could provide some examples down below ⬇️

/r/flask
https://redd.it/1hinlwu
bnap4000 - A simple music player made in made with true randomness in mind.

I have been working on a terminal music player for Linux and Windows. Feel free to suggest or report bugs on GitHub.

What does my project do: It's meant to be a simple, lightweight music player that runs right in your terminal. It's main purpose is to play music randomly and stay out of your way, you just drop music into your music folder and let it play.

Target Audience: Mostly meant for slightly tech savvy people who want something that won't take up a ton of resources, it only uses \~60mb of RAM on my system.

Comparison: I'd compare it to VLC Media player, what I think bnap4000 does better is with simplicity. It has a very simple UI that shows what song is playing, a couple things like volume, a progress bar, and a queue.

GitHub page: https://github.com/0hStormy/bnap4000
bnap stands for Badass New Audio Player if you were wondering.

/r/Python
https://redd.it/1hiqw7l
Where to deploy a flask application ?

Hello,

I have a flask app + a script than runs with a crontab to populate data into a database.

I was wondering, is it better to deploy the app on a linux cloud server ? Or should I use a web hosting plateforms that supports flask out of the box ?





/r/flask
https://redd.it/1hiqjrp
Saturday Daily Thread: Resource Request and Sharing! Daily Thread

# Weekly Thread: Resource Request and Sharing 📚

Stumbled upon a useful Python resource? Or are you looking for a guide on a specific topic? Welcome to the Resource Request and Sharing thread!

## How it Works:

1. Request: Can't find a resource on a particular topic? Ask here!
2. Share: Found something useful? Share it with the community.
3. Review: Give or get opinions on Python resources you've used.

## Guidelines:

Please include the type of resource (e.g., book, video, article) and the topic.
Always be respectful when reviewing someone else's shared resource.

## Example Shares:

1. Book: "Fluent Python" \- Great for understanding Pythonic idioms.
2. Video: Python Data Structures \- Excellent overview of Python's built-in data structures.
3. Article: Understanding Python Decorators \- A deep dive into decorators.

## Example Requests:

1. Looking for: Video tutorials on web scraping with Python.
2. Need: Book recommendations for Python machine learning.

Share the knowledge, enrich the community. Happy learning! 🌟

/r/Python
https://redd.it/1hixdkr
ShortMoji: Emoji Shortcuts Made Easy for Your Keyboard! 🧑‍💻

# What My Project Does

ShortMoji is a lightweight, open-source program that lets you insert emojis anywhere using simple, intuitive keyboard shortcuts. Inspired by Discord's emoji system, it supports **89 unique emoji shortcuts** (and counting!) to make your conversations and workflows more expressive.

Simply type a shortcut like `:smi`, and it transforms into 😃 instantly. ShortMoji runs in the background and is designed for speed and ease of use.

**Features include:**

* Fast emoji insertion via shortcuts.
* Low resource consumption.
* Quick program termination by pressing `Esc` twice.
* Free and fully customizable under the MIT license.

# Target Audience

ShortMoji is for anyone who loves emojis and wants a faster way to use them. Whether you're:

* A developer looking for efficiency.
* A casual user who enjoys using emojis.
* A Discord enthusiast already familiar with emoji shortcuts.

# Comparison

While there are other emoji tools available, ShortMoji sets itself apart with:

* **Customizable shortcuts:** Familiar to Discord users and adaptable for others.
* **Open-source freedom:** Unlike proprietary software, you can modify and expand ShortMoji as you like.
* **Minimal resource impact:** A lightweight utility that doesn’t slow down your system.
* **Simple UX:** No need to navigate menus or GUIs—just type and see the magic !

Unlike system-level emoji menus or bloated applications, ShortMoji is

/r/Python
https://redd.it/1hiuasv
How to make a main consumer that dispatches requests to multiple sub-consumers

I need to accomplish three real-time tasks using Django Channels. I need to track the status of my users (if they are online or offline), I need to send them notifications while they're on the site and I need to manage a live chat. I could maintain three separate WebSocket connections to three different consumers but that would be a pretty inefficient use of ressources.

I would prefer to have one main WebSocket connection with a single consumer that dispatches the requests made to it to three sub-consumers to make it nice, clean and efficient while maintaining a clear separation between the three tasks.

How do I do this?

/r/django
https://redd.it/1hj0yq1
Entry Level Django Developer

Hello everyone. I hope the community can help me. I have been practicing Python for a year and build web application projects using Flask and Django so I'm looking for an entry level Django job to improve my skills further, being mentored and gain experience in a company setting. I'm willing to be paid less and no benefits as long as I get the job and gain Django experience.

/r/django
https://redd.it/1hilzaj
How I got a data analytics job of 10LPA | Fresher data analyst interview experience 2024 | Python

Hello guys I am Dharshan, a final year computer science student. In this video, I have share my detailed interview experience with Tredence, where I secured a Data Analyst job offer for 10 LPA! for which I used python to crack the coding questions. I'll be joining in 2025, and I’m excited to walk you through my journey. I have already posted 3 interview experience videos on my channel and the next one will be amazon interview experience. https://youtu.be/aeLL29SHBGw?si=9CULGR5plBDWs-jg

/r/Python
https://redd.it/1hj4ir0
Gunicorn vs Gunicorn with Uvicorn workers

Hi everyone,

I have a fully synchronous Django app running on Gunicorn with Uvicorn workers. However, I’ve run into a problem: I want to use Gunicorn’s instrumentation features and server hooks (pre_request, and post_request), but these aren’t supported with Uvicorn workers.

I’m debating whether to switch from Uvicorn workers to Gunicorn’s default synchronous workers. I’ve read that Uvicorn workers can still offer better performance, even for synchronous apps, so I’m not sure if I should switch or not.

Should I consider alternatives for instrumentation and server hooks, or would it be better to migrate to normal Gunicorn workers? I’d appreciate any advice or recommendations.

Thanks in advance!

/r/django
https://redd.it/1hj9seo
D Struggling to Find My Path in PhD Research

Hi everyone, I hope you don’t mind me venting a bit, but I’m hoping to gain some insight into a challenge I’ve been facing. I’m a second-year PhD student researching time series, and honestly, I thought by now I would have a clear research question. But I don’t, and it’s starting to get to me.

Part of the struggle comes from the overwhelming pressure to pick a “hot” topic. A lot of the research I see in the field feels driven by what I can only describe as Shiny Object Syndrome—chasing the latest trends rather than focusing on work that’s meaningful and substantial. For example, I’ve seen several papers using large language models (LLMs) for time series forecasting. While LLMs are undeniably fascinating, it feels more like an attempt to forcefully fit them into time series because it’s “cool,” not because it’s the best tool for the problem at hand. And I don’t want to be part of that trend.

But here’s the dilemma: How do you choose a research topic that feels both authentic and impactful, especially when everything around you seems so driven by the latest hype? Do you follow these emerging trends, or do you focus on something that

/r/MachineLearning
https://redd.it/1hj6nbf
Djangoroad YouTube channel gone? I've tried to look for the WSGI video for a refresher, but it seems like her channel is gone. :(

https://www.youtube.com/@djangoroad This was her YouTube channel, and her videos really helped me in deploying a containerized Django app for a client (No, seriously, I would've been fk if I didn't watch her video.)

/r/django
https://redd.it/1hjb9u8
(noob q) What's the best way to set up a many-to-many relationship with djangorestframework?

To simplify the scenario:

My app has users and pre-defined cards. Users can build decks using the cards that are available.

So of course I need models for User, Deck, and Card.

Each User:Deck is 1:many - easy, add foreign key to Deck for User/owner

Here's where I'm not sure what the best option is:
Each Deck includes many cards, and each card may belong to many decks.
Should I build a list of cards that belong to the deck, then include them as a single field? (I think this would be slower because I'd have to retrieve the list then query for those cards?)
Or should I build a separate table that has a separate row for each deck-card relation? (So I would take Deck ID, filter DeckCards by deck ID, and all the cards listed are available)

I'm learning about serializers and hyperlinking right now, but not sure what would be the best way to set up my API here. I followed through the DRF tutorial and it looks like they used hyperlinking for 1:many (users:snippets) but not sure if I can do it the same way for many:many.

/r/django
https://redd.it/1hiuol0
[Release 0.4.0] TSignal: A Flexible Python Signal/Slot System for Async and Threaded Python—Now with

Hey everyone!

I’m thrilled to announce TSignal 0.4.0, a pure-Python signal/slot library that helps you build event-driven applications with ease. TSignal integrates smoothly with async/await, handles thread safety for you, and doesn’t force you to install heavy frameworks.

# What’s New in 0.4.0
## Weak Reference Support
You can now connect a slot with weak=True. If the receiver object is garbage-collected, TSignal automatically removes the connection, preventing memory leaks or stale slots in long-lived applications:

```python
# Set weak=True for individual connections
sender.event.connect(receiver, receiver.on_event, weak=True)

# Or, set weak_default=True at class level (default is True)
@t_with_signals(weak_default=True)
class WeakRefSender:
@t_signal
def event(self):
pass

# Now all connections from this sender will use weak references by default
# No need to specify weak=True for each connect call
sender = WeakRefSender()
sender.event.connect(receiver, receiver.on_event) # Uses weak reference

# Once `receiver` is GC’d, TSignal cleans up automatically.
```

## One-Shot Connections (Optional)
A new connection parameter, one_shot=True, lets you disconnect a slot right after its first call. It’s handy for “listen-once” or “single handshake” scenarios. Just set:

```python
signal.connect(receiver, receiver.handler, one_shot=True)
```

The slot automatically goes away after the first emit.

## Thread-Safety Improvements
TSignal’s internal locking and scheduling mechanisms have been refined to further reduce race conditions in high-concurrency environments. This ensures more

/r/Python
https://redd.it/1hj9cjs
Any suggestions to my plan to learn Django?

For a bit of background, I'm a software engineer with 2+ professional YoE exclusively in Python for small scale applications, with some basic experience in FastAPI, MongoDB, PostgreSQL, PyQt and Docker. I would say I'm fairly proficient in core python but virtually no knowledge/experience in the fundamentals of the internet/HTTP/DNS/networking/cloud deployment, etc.

I'm really interested in learning Django which stems from my goal to build a web app that I have in mind + land a Django role in the distant future, whilst also hoping that the aforementioned weak areas will be learnt along the way.

As I'm in no real rush to learn Django and build my idea, I'd like to plan out some reading material hoping to comprehensively cover the main areas, including deployment, payment handling, etc. So, I'm not really interested in the 5-hour speedrun courses on youtube.

I also don't like the idea of jumping head first into building my idea, as I've taken that approach before and it resulted in a lot of undue stress from incessant jumping around which could've been avoided if I learnt things in a intuitively structured way. Also, I do plan on using the django docs for

/r/django
https://redd.it/1hjm9rl