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
Tkinter freezing after successfully executing the code. Have to force quit the kernel and restart everytime on mac m1.



/r/JupyterNotebooks
https://redd.it/1o8rufk
Turn on Wi-Fi via browser in 7 lines?

What My Project Does

The mininterface project creates dialogs that work everywhere, ex. in the browser.

Here is the app that checks the Wi-Fi status and then turns it on/off. By default, it raises a desktop window with the confirmation dialog. See it here: https://imgur.com/a/20476ZN

#!/usr/bin/env python3
from subprocess import checkoutput, Popen
from mininterface import run

cmd = "nmcli", "radio", "wifi"
state = check
output(cmd, text=True).strip() # -> 'enabled' / 'disabled'

m = run() # shows the dialog
if m.confirm(f"The wifi is {state}. Turn it on?"):
Popen(cmd + ("on",))
else:
Popen(cmd + ("off",))#!/usr/bin/env python3

However when you put the interface="web" parameter in the run function or when use launch the file with the MININTERFACE_INTERFACE=webenvironment variable set like this:

$ MININTERFACE_INTERFACE=web ./wifi.py

it starts listening on the HTTP port 64646. That way, you can turn on/off the Wi-Fi status (or do anything else, it's up to you to imagine all the possibilities) remotely.

Target Audience

Even though opening a port needs a security

/r/Python
https://redd.it/1o8yhuk
Looking for developers

Hi Django community. I’m looking for a freelance developer or two to help me rewrite the backend of an application I have been building. I have a degree in computer science, but have never worked as a professional developer, let alone a Django developer. I have built my proof of concept in Django, and now I am looking to hire a Django expert to help me rewrite my project. My goal here is to get professional input on my architecture, as well as to hopefully learn some do’s and don’ts about enterprise level Django. There is budget and I intend to pay fair market rate, I’m not asking for any favors, just looking for the right person. Send me a message if you are interested.

/r/django
https://redd.it/1o8c307
I was tired of writing CREATE TABLE statements for my Pydantic models, so I built PydSQL to automate

Hey,

I'd like to share a project I built to streamline a common task in my workflow. I've structured this post to follow the showcase rules.

What My Project Does:

PydSQL is a lightweight, no dependencies besides Pydantic utility that converts Pydantic models directly into SQL CREATE TABLE statements.

The goal is to eliminate the manual, error-prone process of keeping SQL schemas synchronized with your Python data models.

For example, you write this Pydantic model:

Python

from pydantic import BaseModel
from datetime import date

class Product(BaseModel):
productid: int
name: str
price: float
launch
date: date
isavailable: bool

And PydSQL instantly generates the corresponding SQL:

SQL

CREATE TABLE product (
product
id INTEGER,
name TEXT,
price REAL,
launchdate DATE,
is
available BOOLEAN


/r/Python
https://redd.it/1o9756d
If starting from scratch, what would you change in Python. And bringing back an old discussion.

I know that it's a old discussion on the community, the trade of between simplicity and "magic" was a great topic about 10 years ago. Recently I was making a Flask project, using some extensions, and I stop to think about the usage pattern of this library. Like you can create your app in some function scope, and use current_app to retrieve it when inside a app context, like a route. But extensions like socketio you most likely will create a "global" instance, pass the app as parameter, so you can import and use it's decorators etc. I get why in practice you will most likely follow.


What got me thinking was the decisions behind the design to making it this way. Like, flask app you handle in one way, extensions in other, you can create and register multiples apps in the same instance of the extension, one can be retrieved with the proxy like current_app, other don't (again I understand that one will be used only in app context and the other at function definition time). Maybe something like you accessing the instances of the extensions directly from app object, and making something like route declaration,

/r/Python
https://redd.it/1o98n90
I built a SaaS boilerplate repo in Django that covers everything I would want as a SaaS founder about to build a SaaS!

Thought I'd share with the community my SaaS boilerplate written in Django for the backend and NextJS for the frontend

Tech Stack & Features:

– Frontend: Next.js

– Backend: Django

– Frontend Hosting: Vercel

– Backend Hosting: Render

– Database: PostgreSQL

– Auth: Google Auth

– Payments: Stripe

– Styling: ShadCN + Tailwind CSS

– AI-generated marketing content (OpenAI)

– Social media posting to Reddit & X from dashboard

– Emails via Resend

– Simple custom analytics for landing page metrics

saasboiler.io

/r/django
https://redd.it/1o9b6xw
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/1o9h81g
De-emojifying scripts - setting yourself apart from LLMs

I am wondering if anyone else has had to actively try to set themselves apart from LLMs. That is, to convince others that you made something with blood, sweat and tears rather than clanker oil.

For context, I'm the maintainer of Spectre (https://github.com/jcfitzpatrick12/spectre), a Python program for recording radio spectrograms from software-defined radios. A long while ago, I wrote a setup script - it's the first thing a user runs to install the progam. That script printed text to the terminal indicating progress, and that text included emoji's ✔️

Certainly! Here’s a way to finish your post with a closing sentiment that emphasizes your personal touch and experience:

Markdown

I guess what I'm getting at is, sometimes the little details—like a hand-picked emoji or a carefully-worded progress message—can be a subtle but honest sign that there's a real person behind the code. In a world where so much content is generated, maybe those small human touches are more important than ever.

Has anyone else felt the need to leave these kinds of fingerprints in their work?


/r/Python
https://redd.it/1o9ar5b
Passing the CSRF Token into a form fetched from Django when the Front-End is in React

This is a reddit post about POSTS not being read. Ironic.
Backstory: A Rollercoaster
What am I posting? A sign-up form. A sign-up from I got from Django.

Good news! As Django is the source of my sign-up form, I can add {% csrf_token %} to the template, and have Django handle the rest.
Bad News: My front end is in React, and not in Django. Therefore, the form POST is handled with Javascript, which views {% csrf_token %} as an error.
Good News! The Django documentation has a page on acquiring the csrf token programmatically in javascript: The Django Documentation has a page on csrf token management.
Bad news: Now what? I'm relying on the form to create the POST request, and not manually creating a fetch() object. Forms don't allow me to neatly edit the POST headers.
Good news: From Googling, I found This Blog Post, which suggests that I could add a hidden <input> tag for sending the csrf token. Even better, I checked the DOM, and voila! I have a idden input element with the csrf token.
Bad News: Doesn't work. Perhaps what I presumed was the CSRF

/r/djangolearning
https://redd.it/1o977gw
2-step Process to Upload a File to Azure Storage Blob without Involving the Back-end to Proxy the Upload: Problems Faced

So there is this 2-step upload process I've implemented to store files in my Django back-end backed by Azure Storage Account blobs:
1. Request an upload SAS URL from back-end: The back-end contacts Azure to get a SAS URL with a UUID name and file extension sent by the user. This is now tracked as a "upload session" by the back-end. The upload session's ID is returned along with the SAS URL to the user.
2. Uploading the File and Registration: The front-end running on the browser uploads the file to Azure directly and once successful, it can register the content. How? It sends the upload session ID returned along with the SAS URL. The back-end uses this ID to retrieve the UUID name of the file, it then verifies that the same file exists in Azure and then finally registers it as a Content (a model that represents a file in my back-end).

There are three situations:
1. Upload succeeded and registration successful (desired).
2. Upload failed and registration successful (easily fixable, just block if the upload fails).
3. Upload succeeded but registration failed (problematic).

The problem with the 3rd situation is that the file remains in the Blob Storage but is not registered with the

/r/djangolearning
https://redd.it/1o963yi
Rant: Python imports are convoluted and easy to get wrong

Inspired by the famous "module 'matplotlib' has no attribute 'pyplot'" error, but let's consider another example: numpy.

This works:

from numpy import ma, ndindex, typing
ma.getmask
ndindex.ndincr
typing.NDArray

But this doesn't:

import numpy
numpy.ma.getmask
numpy.ndindex.ndincr
numpy.typing.NDArray # AttributeError

And this doesn't:

import numpy.ma, numpy.typing
numpy.ma.getmask
numpy.typing.NDArray
import numpy.ndindex # ModuleNotFoundError

And this doesn't either:

from numpy.ma import getmask
from numpy.typing import NDArray
from numpy.ndindex import ndincr # ModuleNotFoundError

There are explanations behind this (numpy.ndindex is not a module, numpy.typing has never been imported so the attribute doesn't exist yet, numpy.ma is a module and has been imported by numpy's __init__.py so everything works), but they don't convince me. I see no reason why import A.B should only work when B is a module. And I see no reason why using a not-yet-imported submodule shouldn't just import it implicitly, clearly you were going to import it anyway. All those subtle inconsistencies where you can't be sure whether something

/r/Python
https://redd.it/1o9gyxa
A Full-Stack Django Multi-Tenant Betting & Casino Platform in Django + React

🚀 I built a multi-tenant betting & casino platform in Django that covers everything I’d want to see in a production-grade system!

Thought I’d share with the community my project — Qbetpro, a multi-tenant Django REST API for managing casino-style games, shops, and operators with advanced background processing, caching, and observability built in.

---

### 🌐 Demo
**GitHub Repo**
**Watch the Demo**

---

### 🧱 System Overview

The Qbetpro ecosystem consists of multiple interconnected apps working together under one multi-tenant architecture:

- 🏢 Operator Portal (Tenant Web) – React + Material UI dashboard for operators to manage their casino, shops, and games
- 🏪 Shop Web (Retail Website) – React + Redux front-end for shop owners to manage tickets, players, and transactions
- 🎮 Games – Web games built using React (and other JS frameworks) that communicate with the Django game engine via REST APIs or WebSocket connections. These games handle UI, animations, and timers, while the backend handles logic, results, and validation.
- 🧩 Game Engine (API) – Django REST backend responsible for authentication, result generation, game logic, and transactions
- 📡 Worker Layer – Celery workers handle background game result generation, leaderboard updates, and periodic reporting
- 📊

/r/django
https://redd.it/1o9rwvx
Which language is similar to Python?

I’ve been using Python for almost 5 years now.
For work and for personal projects.

Recently I thought about expanding programming skills and trying new language.

Which language would you recommend (for backend, APIs, simple UI)? Did you have experience switching from Python to another language and how it turned out?

/r/Python
https://redd.it/1o9tvtc
How to make one dropdown field depend upon another dropdown field in django admin?

I have a model like this:

class CourseSection(TimeStampedModel):
course = models.ForeignKey(Course, relatedname='sections')
title = models.CharField(max
length=1000)

I need to make another django model and I want that in my django admin for that model, there should be a dropdown field that shows all the Course objects. Once the course has been selected the second dropdown field shows CourseSection titles, but only for those CourseSections whose course I selected in the first dropdown field.

I can not update the javascript since I am using the default django admin for this. Is this possible? If not then what would be the best way to do something similar?

/r/djangolearning
https://redd.it/1o82h31
I've written an article series about SQLAlchemy, hopefully it can benefit some of you

You can read it here https://fullstack.rocks/article/sqlalchemy/brewing\_with\_sqlalchemy
I'm really attempting to go deep into the framework with this one. Obviously, the first few articles are not going to provide too many new insights to experienced SQLAlchemy users, but I'm also going into some advanced topics, such as:

Custom data types
Polymorphic tables
Hybrid declarative approach (next week)
JSON and JSONb (week after that)

In the coming weeks, I'll be continuing to add articles to this series, so if you see anything that is missing that might benefit other developers (or yourself), let me know.

/r/Python
https://redd.it/1o9zow6
Saving Memory with Polars (over Pandas)

You can save some memory by moving to Polars from Pandas but watch out for a subtle difference in the quantile's different default interpolation methods.

Read more here:
https://wedgworth.dev/polars-vs-pandas-quantile-method/

Are there any other major differences between Polars and Pandas that could sneak up on you like this?

/r/Python
https://redd.it/1oa4r54
I was wrong: SQL is still the best database for Python Flask Apps in 2025 (free friend link)

Back in May 2023 I argued in another tutorial article that you don’t (always) need SQL for building your own content portfolio website. Airtable’s point-and-click UI is nice, but its API integration with Flask still requires plenty of setup — effectively landing you in a weird no-code/full-code hybrid that satisfies neither camp.

https://preview.redd.it/ch7u4t7twovf1.png?width=2464&format=png&auto=webp&s=55dd613223c01be90c6289f3b66c29a1fcc43821

In reality, setting up a PostgreSQL database on Render takes about the same time as wiring up Airtable’s API — and it scales much better. More importantly, if you ever plan to add Stripe payments (especially for subscriptions), SQL is probably the best option. It’s the most reliable way to guarantee transactional integrity and reconcile your records with Stripe’s.

Finally, SQL databases like PostgreSQL and MySQL are open source — meaning no company can suddenly hike up the prices or shut down your backend overnight. That’s why I’ve changed my stance: it’s better to start with SQL early, take the small learning curve hit, and build on solid, open foundations that keep you in control.

I just published an article on Medium with a clear step-by-step guide on how to build your own Flask admin database with Flask-SQLAlchemy, Flask-Migrate, Flask-Admin and Render for Postgres hosting. Here’s the **free friend link** to the article

/r/flask
https://redd.it/1o94dyt