Daily Python News Question, Tips and Tricks, Best Practices on Python Programming Language Find more reddit channels over at @r_channels
Cors Problem with Django in Production - Google Cloud Console
Hi, I'm having a CORS problem with Django on Google Cloud Run. I have tried different configurations, but nothing works. My frontend is on Vercel, a Next.js app. Can someone help me?.
This is my settings.py.
MIDDLEWARE = [
"corsheaders.middleware.CorsMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_CREDENTIALS = True
CORS_ALLOW_HEADERS = ["*"]
/r/django
https://redd.it/1jd2llr
uv starting to overtake Poetry in package download
Downloads chart for Wagtail by installer: uv overtakes Poetry. It’s the first time I pull those kinds of stats and it seem pretty expensive to process the data for all PyPI downloads, so I only pulled a few packages.
/r/Python
https://redd.it/1jd7nhh
Introducing Aurras - A Fast, Feature-Rich Terminal Music Player (Spotify, YouTube, Offline, TUI/CLI)
Hey r/python community, I've been tinkering with a project for the past few months, and I thought some of you might find it interesting. It's a terminal-based music player called Aurras, and honestly, it started because I was just scratching my own itch.
# Target Audience
Like a lot of you, I spend a lot of time in the terminal. I love the efficiency, but I always found it a bit jarring to switch over to a separate music player. So, I started playing around with the idea of a music player that could live right in my terminal.
# What my Project Does?
Basically, it lets you listen to music without leaving your command line. You can use it in a traditional CLI way, or there's a more modern TUI built with Textual if you prefer something more interactive(TUI support will be added in later releases). It handles online song streaming, local file playback, playlist management, lyrics, and even Spotify playlist imports.
Choose your interface: CLI or TUI, whatever suits your style.
Online song streaming: Stream directly without downloads.
Local playback: Play your offline music.
Playlist management: Create, edit, and organize your playlists.
Spotify integration: Import your Spotify playlists (securely, of course).
Lyrics
/r/Python
https://redd.it/1jd5o5s
Embarking on My Django Journey – Seeking Guidance & Resources
Hello everyone,
I have a solid understanding of Python fundamentals, object-oriented programming, and basic HTML and CSS. However, I haven't ventured into JavaScript yet, as frontend styling hasn't particularly appealed to me, and the prospect of learning a new language solely for that purpose seems daunting.
This led me to explore backend development with Python, and I discovered Django. While I understand that Django is a backend framework, my knowledge about it is limited.
I'm eager to start learning Django but am uncertain about where to begin and which resources to utilize. I would greatly appreciate any guidance on effectively navigating this learning path to become a proficient backend developer.
Additionally, I've noticed that some websites built with Django appear outdated or simplistic. How can I ensure that the websites I create with Django have a modern and appealing design?
Furthermore, considering my lack of JavaScript knowledge, will I be able to integrate the Django backend with a pre-made frontend effectively?
If anyone else is starting with Django, please upvote and share the resources you're using! Let's embark on this learning journey together.
Thank you!
/r/djangolearning
https://redd.it/1jcuqlr
Django celery
Hello guys, I wan tot know if I can found a free server to host redis and user celery I Want for send scheduled emails.
/r/django
https://redd.it/1jd1ofc
How to safely host Django locally?
I've just got my public IP from my ISP and I wonder which security risks I need to take care when opening a port and letting my PC available to the web.
How much better will it be to just host on AWS or Heroku?
/r/django
https://redd.it/1jcpanc
Should I skip the first 2 projects for this tutorial
I am watching the 10hr long freeCodeCamp Django tutorial by tomi. The thing is I wanted to just directly get to the realtime chat application as I have a hackathon coming up where I have to build the same. Therefore I was planning on skipping the first 2 projects, being A blog and a weather app. Should I skip or just pull an all nighter and complete the whole thing?
/r/djangolearning
https://redd.it/1jchk87
Polars Plugin for List-type utils and signal processing
\# What My Project Does
It is a Polars Plugin to facilitate working with List-type data in Polars, in particular for signal processing
\# Target Audience (e.g., Is it meant for production, just a toy project, etc.
Data Scientists working with List-type data in Polars or considering using Polars for their work on signal data.
\# Comparison (A brief comparison explaining how it differs from existing alternatives.)
Currently there are no Polars-native alternatives for these methods except for elementwise aggregation, but as I describe below this provides a number of benefits to Polars-native approaches. The only other alternative for the other methods is converting your data to Numpy, doing your work there, and then moving it back into Polars which breaks most of the query optimization and parallelization benefits of Polars.
\# The story:
I made a Polars plugin (mostly for myself at work, but I hope others can benefit from this as well) with some helpers and operations for List-type columns. It is in a bit of a pragmatic state, as I don't have so much time at work to polish it beyond what I need it for but I definitely intend on extending it over time and adding a proper documentation page.
Currently it can do
/r/Python
https://redd.it/1jci6px
A Very Early Play With Astral's Red Knot Static Type Checker
https://jurasofish.github.io/a-very-early-play-with-astrals-red-knot-static-type-checker.html
I've just had a play with the new type checker under development as part of ruff. Very early, as it's totally unreleased, but so far the performance looks extremely promising.
/r/Python
https://redd.it/1jcgh0o
Driver Fatigue Monitoring
made a cool Drowsiness Detector
check it out, leave a comment if u have any suggestions or want to collaborate
https://github.com/SomnoCam/Drowsiness-Detector.git
/r/Python
https://redd.it/1jca2ny
Made a Youtube Downlaoder and Thumbnail Tester
Made a Youtube Video downloader and a Thumbnail Tester. Also looking to add a braille AI translator I made.
I made it cause I am an editor and download a lot of youtube vids, but most of the sites are really bad and scammy. Check it out if you want :)
/r/flask
https://redd.it/1j9q1ha
Unvibe: Generate code that passes Unit-Tests
# What My Project Does
Unvibe is a Python library to generate Python code that passes Unit-tests.
It works like a classic unittest
Test Runner, but it searches (via Monte Carlo Tree Search)
a valid implementation that passes user-defined Unit-Tests.
# Target Audience (e.g., Is it meant for production, just a toy project, etc.)
Software developers working on large projects
# Comparison (A brief comparison explaining how it differs from existing alternatives.)
It's a way to go beyond vibe coding for professional programmers dealing with large code bases.
It's an alternative to using Cursor or Devon, which are more suited for generating quick prototypes.
## A different way to generate code with LLMs
In my daily work as consultant, I'm often dealing with large pre-exising code bases.
I use GitHub Copilot a
/r/Python
https://redd.it/1jbv74v
Django Query Optimization - Defer, Only, and Exclude
https://testdriven.io/blog/django-query-optimization/
/r/django
https://redd.it/1jbw1sh
R Transformers without Normalization (FAIR Meta, New York University, MIT, Princeton University)
Transformers without Normalization
Jiachen Zhu, Xinlei Chen, Kaiming He, Yann LeCun, Zhuang Liu
arXiv:2503.10622 [cs.LG\]: https://arxiv.org/abs/2503.10622
Abstract: Normalization layers are ubiquitous in modern neural networks and have long been considered essential. This work demonstrates that Transformers without normalization can achieve the same or better performance using a remarkably simple technique. We introduce Dynamic Tanh (DyT), an element-wise operation DyT(x)=tanh(αx), as a drop-in replacement for normalization layers in Transformers. DyT is inspired by the observation that layer normalization in Transformers often produces tanh-like, S-shaped input-output mappings. By incorporating DyT, Transformers without normalization can match or exceed the performance of their normalized counterparts, mostly without hyperparameter tuning. We validate the effectiveness of Transformers with DyT across diverse settings, ranging from recognition to generation, supervised to self-supervised learning, and computer vision to language models. These findings challenge the conventional understanding that normalization layers are indispensable in modern neural networks, and offer new insights into their role in deep networks.
code and website: https://jiachenzhu.github.io/DyT/
Detailed thread on X by Zhuang Liu: https://x.com/liuzhuang1234/status/1900370738588135805
https://preview.redd.it/c017auy7ztoe1.jpg?width=1116&format=pjpg&auto=webp&s=e87b7d0ddd44df8f5a7f789365bf128113307539
/r/MachineLearning
https://redd.it/1jbs7xg
Made a full body workout app
So i had this idea for a while now and this isnt the first version (first 2 were kivy apps), but i built a workout app.
excercises are selected randomly based on what level you set(1->4), videos are embeded youtube videos, equipments can be toggled or off.once you are satiffied with the preview you can accept it at the bottom of the page. the app is kind of ugly which is one thing i want to ask about, i am no front dev so any ideas about color and such or resources how to pick better colors, gaps, styling is welcome, i got no experience,i read the book: the design of everyday things and in usability it did give some great pointers but the page is just ugly.
the app is in beta so there are some bugs. you can log in with a guest account or you can also make a profile.(note that for now there is no extensive regex but the email has to contain gmail in it)
working on a major update that will add lower- upper split routine , and a routine builder for more flexible workouts.
front end uses some js and self cooked css, as well as bootstrap.
/r/flask
https://redd.it/1j9q0k2
Basic Memory: A Python-based Local-First Knowledge Graph for LLMs
# What My Project Does
Basic Memory is an open-source Python tool that creates a persistent knowledge graph from standard Markdown files to enhance LLM interactions. It works by:
* Using simple Markdown files as the primary storage medium
* Extracting semantic meaning from markdown patterns to build a knowledge graph
* Providing bi-directional synchronization between files and graph structure
* Integrating with Claude Desktop via the Model Context Protocol (MCP)
The system extracts semantic meaning from simple Markdown patterns:
- [category] Observation about a topic #tag (optional context)
- relation_type [[WikiLink]] (optional context)
Check out a short demo video showing Basic Memory in action: [https://basicmachines.co/images/Claude-Obsidian-Demo.mp4](https://basicmachines.co/images/Claude-Obsidian-Demo.mp4)
GitHub: [https://github.com/basicmachines-co/basic-memory](https://github.com/basicmachines-co/basic-memory)
Documentation: [https://memory.basicmachines.co/](https://memory.basicmachines.co/)
# Target Audience
Basic Memory is intended for:
* Researchers and knowledge workers who need to maintain context across multiple LLM conversations
* Developers working on LLM-powered applications who need a persistent memory layer
* Obsidian users looking to enhance their notes with AI capabilities
* Anyone looking for a production-ready, local-first solution for AI memory that respects data ownership
This is a fully functional production tool, not just a toy project. It's designed with data privacy in mind - everything stays on your local machine.
# Comparison
Unlike other memory solutions for LLMs:
* **vs. Built-in LLM memory** (like ChatGPT's memory): Basic
/r/Python
https://redd.it/1jctt1v
Installing requirements.txt taking forever...
I am working on a project and messed up something and it refuses to migrate. so i renamed the directory and cloned the last working commit. then I try to install requirements.txt and its taking forever. for last 10 minutes it is installing matplotlib. It is going somewhere just very very slowly. (using VScode, Ubuntu 24.04, AMD 3500U laptop.)
/r/djangolearning
https://redd.it/1jd6vaj
Monday Daily Thread: Project ideas!
# Weekly Thread: Project Ideas 💡
Welcome to our weekly Project Ideas thread! Whether you're a newbie looking for a first project or an expert seeking a new challenge, this is the place for you.
## How it Works:
1. **Suggest a Project**: Comment your project idea—be it beginner-friendly or advanced.
2. **Build & Share**: If you complete a project, reply to the original comment, share your experience, and attach your source code.
3. **Explore**: Looking for ideas? Check out Al Sweigart's ["The Big Book of Small Python Projects"](https://www.amazon.com/Big-Book-Small-Python-Programming/dp/1718501242) for inspiration.
## Guidelines:
* Clearly state the difficulty level.
* Provide a brief description and, if possible, outline the tech stack.
* Feel free to link to tutorials or resources that might help.
# Example Submissions:
## Project Idea: Chatbot
**Difficulty**: Intermediate
**Tech Stack**: Python, NLP, Flask/FastAPI/Litestar
**Description**: Create a chatbot that can answer FAQs for a website.
**Resources**: [Building a Chatbot with Python](https://www.youtube.com/watch?v=a37BL0stIuM)
# Project Idea: Weather Dashboard
**Difficulty**: Beginner
**Tech Stack**: HTML, CSS, JavaScript, API
**Description**: Build a dashboard that displays real-time weather information using a weather API.
**Resources**: [Weather API Tutorial](https://www.youtube.com/watch?v=9P5MY_2i7K8)
## Project Idea: File Organizer
**Difficulty**: Beginner
**Tech Stack**: Python, File I/O
**Description**: Create a script that organizes files in a directory into sub-folders based on file type.
**Resources**: [Automate the Boring Stuff: Organizing Files](https://automatetheboringstuff.com/2e/chapter9/)
Let's help each other grow. Happy
/r/Python
https://redd.it/1jczjes
Finally deployed my Flask app… and wow, I was NOT ready for this
So I finally deployed my first real Flask app, and let’s just say… I learned a lot the hard way. Thought I’d share in case it helps someone else (or at least gives you a laugh).
Spent hours debugging why my app worked locally but not on the server—turns out, I forgot to install Gunicorn. Flask’s built-in server is NOT for production. Lesson learned.
Hardcoded some API keys while testing and totally forgot about them. Almost pushed them to GitHub. Use environment variables, people.
Didn’t properly close my DB connections, so my app kept dying under even light load. SQLAlchemy’s connection pooling saved me.
Thought Docker was overkill. Spoiler: it’s not. Spinning up my app with a single docker-compose up is a game-changer.
Spent way too long fighting CORS issues. Flask-CORS was the easy fix, but I went down a rabbit hole first.
/r/flask
https://redd.it/1jcdaux
How to create websites and practice backend without having front-end knowledge?
Someones who work with django or other backend's frameworks say to me that how can i do it without front end knowledge? i can just write html and css but i dont know about js.
I think this is a challenge for backend developers who dont have anyone for the front-end side, if they dont work full stack.
/r/django
https://redd.it/1jcoro8
Release tkinter-embed: Install Tkinter for Windows Embedded Python via pip
If you distribute Python applications on Windows using embedded Python, you've likely struggled with installing GUI libraries like Tkinter. Until now, this required manual file copying (see this Stack Overflow thread), which is error-prone and time-consuming. Introducing **tkinter-embed**:
A PyPI package that automates Tkinter installation for embedded Python environments. Now you can use pip
directly!
# What My Project Does
tkinter-embed solves Tkinter installation for Windows Embedded Python distributions through a pip-installable package. It automatically copies required DLLs, libraries, and support files to create functional GUI applications without manual file operations. Enables Tkinter-based GUI development in portable Python environments.
# Target Audience
Primarily for developers who:
Distribute portable Windows apps using embedded Python
Create self-contained tools for non-technical users
# Installation Guide
# Step 1: Install pip
Choose one method:
Method 1: Use pip.pyz (recommended)
Method 2: Use get-pip.py
.\python get-pip.py --target .
# Step 2: Install setuptools
In your embedded Python folder:
.\python pip.pyz install setuptools --target .
OR if you used get-pip.py
.\python -m pip install setuptools --target .
# Step 3: Install tkinter-embed
In your embedded Python folder:
.\python pip.pyz install tkinter-embed --target .
OR if you used get-pip.py
.\python -m pip install tkinter-embed --target .
After completing these steps, Tkinter
/r/Python
https://redd.it/1jcnbtx
Stereo-Hands: Stereo panning on the basis of hand gestures ( Hand control music in 3D )
What it does: It captures real time image from camera, traces hand positioning and recognizes fingertips and adjust stereo of the music accordingly to give the feeling of hand control for 3d music experience
Target audience: Developer who seek cool projects.
Comparison: It's a original idea only intended for fun, so no comparison I guess?
Here is the Code.
/r/Python
https://redd.it/1jcean2
Introducing Eventure: A Powerful Event-Driven Framework for Python
**Eventure** is a Python framework for simulations, games and complex event-based systems that emerged while I was developing something else! So I decided to make it public and improve it with documentation and examples.
## What Eventure Does
Eventure is an event-driven framework that provides comprehensive event tracking, querying, and analysis capabilities. At its core, Eventure offers:
- **Tick-Based Architecture**: Events occur within discrete time ticks, ensuring deterministic execution and perfect state reconstruction.
- **Event Cascade System**: Track causal relationships between events, enabling powerful debugging and analysis.
- **Comprehensive Event Logging**: Every event is logged with its type, data, tick number, and relationships.
- **Query API**: Filter, analyze, and visualize events and their cascades with an intuitive API.
- **State Reconstruction**: Derive system state at any point in time by replaying events.
The framework is designed to be lightweight yet powerful, with a clean API that makes it easy to integrate into existing projects.
Here's a quick example of what you can do with Eventure:
```python
from eventure import EventBus, EventLog, EventQuery
# Create the core components
log = EventLog()
bus = EventBus(log)
# Subscribe to events
def on_player_move(event):
# This will be linked as a child event
bus.publish("room.enter",
/r/Python
https://redd.it/1jchkuc
FastOpenAPI library Flask, Falcon, Quart, Sanic, Starlette
While working on a project that required OpenAPI documentation across multiple frameworks, I got tired of maintaining different solutions. I really like FastAPI’s routing—it’s clean and intuitive. So I built FastOpenAPI, which brings a similar approach to other frameworks.
# What FastOpenAPI Does
FastAPI-style routing, but without being tied to FastAPI.
Automatic OpenAPI documentation generation.
Built-in request validation with Pydantic.
Supports Flask, Falcon, Sanic, Starlette, and Quart.
# Target Audience
FastOpenAPI is designed for web developers who like FastAPI-style routing but need to use a different framework for various reasons. It’s a compromise solution for those who want a clean and intuitive API but cannot use FastAPI.
# Comparison
Compared to existing solutions:
Not tied to FastAPI, unlike FastAPI itself, which is built on Starlette.
Unified routing style and OpenAPI generation across multiple frameworks.
Built-in request validation with Pydantic, whereas many frameworks require manual data parsing and validation.
Simpler and more concise syntax than Flask-Smorest or Spectree, which use different approaches.
The project is still evolving, and I’d love any feedback or testing from the community!
📌 GitHub: https://github.com/mr-fatalyst/fastopenapi
📦 PyPI: https://pypi.org/project/fastopenapi/
/r/Python
https://redd.it/1jc4ffr
R Recent advances in recurrent neural networks---any sleepers?
title; all i hear is mamba when it comes to recurrent neural networks these days. which recurrent neural network framework are you optimistic for?
/r/MachineLearning
https://redd.it/1jbzcoc
Sunday Daily Thread: What's everyone working on this week?
# Weekly Thread: What's Everyone Working On This Week? 🛠️
Hello /r/Python! It's time to share what you've been working on! Whether it's a work-in-progress, a completed masterpiece, or just a rough idea, let us know what you're up to!
## How it Works:
1. Show & Tell: Share your current projects, completed works, or future ideas.
2. Discuss: Get feedback, find collaborators, or just chat about your project.
3. Inspire: Your project might inspire someone else, just as you might get inspired here.
## Guidelines:
Feel free to include as many details as you'd like. Code snippets, screenshots, and links are all welcome.
Whether it's your job, your hobby, or your passion project, all Python-related work is welcome here.
## Example Shares:
1. Machine Learning Model: Working on a ML model to predict stock prices. Just cracked a 90% accuracy rate!
2. Web Scraping: Built a script to scrape and analyze news articles. It's helped me understand media bias better.
3. Automation: Automated my home lighting with Python and Raspberry Pi. My life has never been easier!
Let's build and grow together! Share your journey and learn from others. Happy coding! 🌟
/r/Python
https://redd.it/1jc8qu4
Struggling to Land US/Western Europe Remote Roles as an Indian Django Developer – Need Advice
Hi everyone,
I’m a Django developer with 4 years of experience, currently based in India. Despite my remote work experience with international companies (including projects for teams in the Netherlands and The Bahamas), I keep hitting a wall. Most remote job applications seem to be met with responses like “we don’t hire from India” or “we’re looking for someone with more experience or cultural fit.”
I understand that factors such as purchase power parity play a part in salary negotiations and market rates. However, I feel that my location is unfairly limiting my opportunities and undervaluing my skills. I’m eager to work with US or Western European companies that appreciate quality and expertise, regardless of where I’m based.
I’m reaching out to this community for advice:
How can I better position my skills and remote work experience to overcome the location bias?
Has anyone successfully navigated similar challenges? If so, what strategies or platforms did you find most effective?
Any tips for tweaking my resume or application approach to appeal to international employers?
how much should i expect in salary since i have 4 years of experience & i dont have a CS degree.
p.s. i post my learnings on twitter and on my blog.
my portfolio - https://sorv.dev
/r/flask
https://redd.it/1jbvje6
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/1jbi7gc
Created a web application to allow users to evaluate their options for cars to purchase on a deeper level
As the title suggests, I created a web application using flask and some very basic bootstrap to add a whole new level to comparing different vehicles. Yeah MPG is important, but does that really matter when you have to lay down an extra $5,000 down and have to pay an extra $300 per month? Maybe not so much anymore, and how about maintenance and driving habits?
The page is broken down into two sections:
Global: shows variables like the interest rate on a loan you can get, estimated time you plan on owning the car, how many miles you drive per month, fuel price, and driving habbits (ie, I drive 80% on the highway and 20% in the city
Variables for up to 3 cars: Car name, down payment, monthly payment on the loan, average monthly maintenance, and city/highway mpg
Once you enter this information in, you will be taken to a page that shows what the total cost of ownership (TCO) is for each vehicle over the period of time you want to own it. The car with the lowest TCO will be the least expensive car.
This application will help you make these decisions by looking at the total cost of
/r/flask
https://redd.it/1j9gchf
.csv file truncates data no matter what
I am working on using pandas to automate combining, sorting, and counting music playlists at the college station at which I am the faculty advisor.
I can import the files over the station network, create a data frame that pulls the specific data I want, but I cannot seem to get the full data set. No matter how many different ways to set to display the full set, it truncates the dada frame, only showing the first/last three list entries.
here is my block:
import pandas as pd
df = pd.read_csv(r”net path\file.csv”, encoding = “ANSI”, header = None)
data = df.iloc[:, [2, 3, 4]].values
pd.set_option(“display.max_rows”, None)
any suggestions?
/r/Python
https://redd.it/1jbemnx