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
Just Released Version 0.4.0 of Django Action Triggers!

First off, a huge thank you to everyone who provided feedback after the release of version 0.1.0! I've taken your input to heart and have been hard at work iterating. I’m excited to announce the release of **version 0.4.0** of **django-action-triggers**.

There’s still more to come in terms of features and addressing suggestions, but here’s an overview of the current progress.

# What is Django Action Triggers

[Django Action Triggers](https://github.com/Salaah01/django-action-triggers) is a Django library that lets you trigger specific actions based on database events, detected via Django Signals. With this library, you can configure **actions** that run asynchronously when certain triggers (e.g., a model save) are detected.

For example, you could set up a trigger that hits a webhook and sends a message to AWS SQS whenever a new sale record is saved.

# What's New in Version 0.4.0?

Here’s a quick comparison of **version 0.1.0** vs. **version 0.4.0**:

**Version 0.1.0** features:

* Webhook integration
* RabbitMQ integration
* Kafka integration

**Version 0.4.0** features:

* Webhook integration
* RabbitMQ integration
* Kafka integration
* Redis integration
* AWS SQS (Simple Queue Service) integration
* AWS SNS (Simple Notification Service) integration
* Actions all run asynchronously
* Actions can have a timeout

# Looking Forward

As always, I’d love to hear your feedback. This project started as a passion project but has

/r/djangolearning
https://redd.it/1fc2svw
PyWeek 38: A Python Game Jam

PyWeek is a twice-a-year game jam (that's been running for over 15 years) where you have a week to create a game in Python that fits the theme voted on by the community. You can enter by yourself or with a team of your choosing. The games are judged and voted on by the other PyWeek participants.

Once you've signed, you can immediately go vote on the different themes! Head over here to vote: [https://pyweek.org/p/42/](https://pyweek.org/p/42/)


**Important Dates**

* Theme is revealed and PyWeek starts: Sunday, September 15th, 2024 (midnight UTC)
* Challenge ends: Sunday, September 22nd (midnight UTC)
* Judging ends & winners announced: Sunday, October 6th (midnight UTC)


**Helpful Links & Other Info**

* Sign up on the PyWeek website: [https://pyweek.org/38/](https://pyweek.org/38/)
* PyWeek Rules: [https://pyweek.readthedocs.io/en/latest/rules.html](https://pyweek.readthedocs.io/en/latest/rules.html)


If you're interested in working with other folks or have more questions, there is a dedicated channel over on the Python Discord server for PyWeek. You're welcome to ping me directly there.

I'll also try to keep an eye on this thread if folks have questions\~

/r/Python
https://redd.it/1fccov9
Build web applications with wwwpy: For backend developers looking to minimize frontend headaches

All while providing strong customization, extension, and scalability!

Hey guys, my name is Simon and this is my first post.

I'm here for two reasons. One, share some thoughts about libraries you may be familiar with, like: Streamlit, Gradio, Dash, Anvil, Panel, Reflex, Taipy, NiceGUI, Remo, Pyweb, PyJs, Flet, Mesop and Hyperdiv. Two, get to know what problems you are dealing with that pushed you to use one of the above.

Don't get me wrong, the libraries listed have amazing features but I'm purposely looking at the missing parts.

Here are some pain points I've identified:

Slow UI rendering with big datasets or multiple visualization
Difficult to scale programming model and UI interaction
Extending or building components is costly, difficult or involving long toolchains
Overly simplistic architectures for complex applications
Scalability challenges in transitioning from demos to fully-fledged applications
Python runs server-side, while browser capabilities remain distant and restricted by the framework's architecture. (markdown, server side api, pushing updates to the DOM)



The famous libraries mentioned are particularly close to my heart because it's the field where I invested the most time working on. I've been developing software as a consultant for nearly 35 years and in the last 15 I developed web applications and

/r/Python
https://redd.it/1fcwvuk
Library for generating REST API clients using methods annotated with type hints

What My Project Does

Meatie is a Python metaprogramming library that eliminates the need for boilerplate code when integrating with REST APIs. The library generates code for calling a REST API based on method signatures annotated with type hints. Meatie abstracts away mechanics related to HTTP communication, such as building URLs, encoding query parameters, serializing and deserializing request and response body. With some modest additional configuration, generated methods provide rate limiting, retries, and caching. Meatie works with major HTTP client libraries (request, httpx, aiohttp). It offers integration with Pydantic V1 and V2. The minimum officially supported version is Python 3.9.

Code Example

from typing import Annotated
from aiohttp import ClientSession
from meatie import api_ref, endpoint
from meatie_aiohttp import Client
from meatie_example.store import Product, Basket, BasketQuote # Pydantic models

class OnlineStore(Client):
def init(self, session: ClientSession) -> None:
super().init(session)

@endpoint("/api/v1/products")


/r/Python
https://redd.it/1fcz4bd
Tuesday Daily Thread: Advanced questions

# Weekly Wednesday Thread: Advanced Questions 🐍

Dive deep into Python with our Advanced Questions thread! This space is reserved for questions about more advanced Python topics, frameworks, and best practices.

## How it Works:

1. **Ask Away**: Post your advanced Python questions here.
2. **Expert Insights**: Get answers from experienced developers.
3. **Resource Pool**: Share or discover tutorials, articles, and tips.

## Guidelines:

* This thread is for **advanced questions only**. Beginner questions are welcome in our [Daily Beginner Thread](#daily-beginner-thread-link) every Thursday.
* Questions that are not advanced may be removed and redirected to the appropriate thread.

## Recommended Resources:

* If you don't receive a response, consider exploring r/LearnPython or join the [Python Discord Server](https://discord.gg/python) for quicker assistance.

## Example Questions:

1. **How can you implement a custom memory allocator in Python?**
2. **What are the best practices for optimizing Cython code for heavy numerical computations?**
3. **How do you set up a multi-threaded architecture using Python's Global Interpreter Lock (GIL)?**
4. **Can you explain the intricacies of metaclasses and how they influence object-oriented design in Python?**
5. **How would you go about implementing a distributed task queue using Celery and RabbitMQ?**
6. **What are some advanced use-cases for Python's decorators?**
7. **How can you achieve real-time data streaming in Python with WebSockets?**
8. **What are the

/r/Python
https://redd.it/1fd4fhr
Laravel raises a $57 million series A from Accel – what about Django?


https://laravel-news.com/laravel-raises-57-million-series-a

Laravel has pulled in $57M from Accel, and it’s got me wondering on why isn’t Django receiving similar financial recognition? What’s holding Django back, and how do we as a community make sure we stay competitive? Thoughts?

/r/django
https://redd.it/1fcsgjn
What are some good open-source projects to contribute to?

I’m looking to get involved in open-source and would love your suggestions for projects related to Django that need contributors. Whether they’re beginner-friendly or more advanced, I’m open to any recommendations!

/r/django
https://redd.it/1fcudnc
Computational Collision Physics

Hello, so I recently wrote a paper on my Python project based on collision physics. If possible, I would to love to hear anyone's honest feedback about it and possible areas of improvement. Additionally, could anyone suggest any other notable academic sites where I can publish my paper?

https://www.academia.edu/123663289/Computational\_Physics\_Collision\_Project

/r/Python
https://redd.it/1fd9k40
What job boards do you use?

I've been looking for a senior Django (also Flask or FastAPI) dev for a couple of months now and the quality of candidates I got was abysmal.

So I'm wondering if I'm using the wrong channel (Linkedin). Where do you guys typically look for jobs?

/r/django
https://redd.it/1fdd99j
Issue: Microsoft SSO Integration State Mismatch (Django + Azure App Service)

I’m working on integrating Microsoft SSO into my Django app (hosted on Azure App Service). The SSO login flow seems to work up to the point where the callback is received, but I’m consistently encountering a "State Mismatch" error. I’ve tried multiple solutions, and I’m hoping someone could help me resolve this issue.

# Django & Azure Configuration:

Django version: 5.0.6
Python version: 3.12
SSO Integration Package: `django-microsoft-sso`
Azure App Service: Hosted with App Service Plan for deployment.
Time Zone: Central Time (US & Canada) on local development and UTC on the Azure server.
Session Engine: Using default Django session engine with database-backed sessions (django.contrib.sessions.backends.db).

ERROR 2024-09-09 14:12:40,723 - State Mismatch. Time expired?

INFO "GET /microsoft_sso/callback/?code=... HTTP/1.1" 302 0

DEBUG views Login failed at 2024-09-09 19:xx:xxpm: Displaying login_failed page.

DEBUG views Session ID during login_failed: None

DEBUG views Session contents during login_failed: {}

DEBUG views CSRF token during login_failed: None

SSO Callback Code:

import logging

import os

import binascii

from django.contrib.auth import login

from django.shortcuts import redirect, render

from django.urls import reverse

from django.conf import settings

from django.contrib.auth.models import User

from django.utils.timezone import now

logger = logging.getLogger(__name__)

def microsoft_sso_callback(request):

logger.debug(f"Start Microsoft SSO login. Current Server Time: {now()}")

# Retrieve the state from the callback and session

state = request.GET.get('state')

session_state = request.session.get('oauth2_state')

logger.debug(f"Received state in callback: {state}")

logger.debug(f"Session state before validation: {session_state}")

logger.debug(f"Session ID during callback: {request.session.session_key}")

logger.debug(f"Session contents during callback: {dict(request.session.items())}")

#

/r/djangolearning
https://redd.it/1fd83fu
Seasoned Developers: What does you .gitignore look like?

Help a novice out. When building with Django, what are the essentials to add to a gitignore file before pushing to remote?

/r/django
https://redd.it/1fdigtr
A web UI for SQLAlchemy to integrate into your web apps

# What my project does

I was missing a UI to visualize my DB schema, quickly check what's in the DB, see the migrations, etc. So you know what happened next :S

I created a very simple PoC to visualize the tables and relationships of a DB, later I'm planning data visualization and alembic migrations view/management/don't know possibly some git integration to check for DB changes on other branches. The idea is to integrate the UI into your existing web application, for the moment I only support FastAPI and Starlette:

pip install dbstudio

from dbstudio.fastapi import getfastapirouter

app = FastAPI()
app.mount("/dbstudio", getfastapirouter(engine))

Link to repo: https://github.com/lucafaggianelli/dbstudio

# Target Audience

The project is meant to be used during development and not in production as an admin panel or whatever

# Comparison

I was inspired by Prisma, an ORM for NodeJS that ships with its own Studio and ChartDB a tool to visualize DB schemas offline running a SQL query, I didn't find much for the SQLAlchemy world only sqladmin for FastAPI, but it doesn't show the DB schema, is more a data editor and some projects for Flask.

The alternative is to use tools like DB browser for

/r/Python
https://redd.it/1fdje37
I made an app to visualize H1B visa data

Inspired by a post in another subreddit so I made this webapp in Flask. You can query and visualize data from H1B visa applications. So far I've only included roughly 9 months data there. It shows that "Web Devs" average salary is only $68k, even behind English teachers lol.

https://preview.redd.it/p6q2cqi2j1od1.png?width=901&format=png&auto=webp&s=f779706cf85a14c3684852daae12daa85974114a

https://urchin-app-qdr2l.ondigitalocean.app/by-soc-occupational-title

Still very early prototype as you can tell and don't even have a domain yet.

Really love Flask for it's simplicity and extensibility, I can see myself sticking to Flask most of time.

Happy to hear your thoughts & questions!

/r/flask
https://redd.it/1fdrx9q
Best Django Courses

I am a Senior Frontend Developer with +7 years. The company I am already working has a Tech Stack with Django.

One of my mission is getting certificate related to our tech stack. I want to learn Django with advanced backend concepts because it is opportunity for me.

I know that the best way to learn a new technology is reading and applying the docs. But my company rule is collecting certificate as well.

What are your suggestions in this point? Which courses do you suggest to me? Thanks in advance 🖖

/r/django
https://redd.it/1fds72q
Wednesday Daily Thread: Beginner questions

# Weekly Thread: Beginner Questions 🐍

Welcome to our Beginner Questions thread! Whether you're new to Python or just looking to clarify some basics, this is the thread for you.

## How it Works:

1. Ask Anything: Feel free to ask any Python-related question. There are no bad questions here!
2. Community Support: Get answers and advice from the community.
3. Resource Sharing: Discover tutorials, articles, and beginner-friendly resources.

## Guidelines:

This thread is specifically for beginner questions. For more advanced queries, check out our [Advanced Questions Thread](#advanced-questions-thread-link).

## Recommended Resources:

If you don't receive a response, consider exploring r/LearnPython or join the Python Discord Server for quicker assistance.

## Example Questions:

1. What is the difference between a list and a tuple?
2. How do I read a CSV file in Python?
3. What are Python decorators and how do I use them?
4. How do I install a Python package using pip?
5. What is a virtual environment and why should I use one?

Let's help each other learn Python! 🌟

/r/Python
https://redd.it/1fdwqji
Dict Hash: Efficient Hashing for Python Dictionaries

# What My Project Does

Dict Hash is a Python package designed to solve the issue of hashing dictionaries and other complex data structures. By default, dictionaries in Python aren’t hashable because they’re mutable, which can be limiting when building systems that rely on efficient lookups, caching, or comparisons. Dict Hash provides a simple and robust solution by allowing dictionaries to be hashed using Python’s native hash function or other common hashing methods like sha256.

It also supports hashing of Pandas and Polars DataFrames, NumPy arrays, and Numba objects, making it highly versatile when working with large datasets or specialized data structures. Of course, the package can hash recursively, so even dictionaries containing other dictionaries (or nested structures) can be hashed without trouble. You can even implement the Hashable interface and add support for your classes.

One of the key features of Dict Hash is its approximated mode, which provides an efficient way to hash large data structures by subsampling. This makes it perfect for scenarios where speed and memory efficiency are more important than exact precision while maintaining determinism, meaning that the same input will always result in the same hash, even when using approximation. Typically we use this when processing large

/r/Python
https://redd.it/1fdkpkz