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
PayPal vs. Stripe for Django Donations: Which Payment Gateway is Best for a Charity Site?

I’m building a charity website where the admin can manage content and handle donations. Historically, the client used PayPal for donations, but I’m considering using Stripe instead, given the better-maintained Django modules for Stripe.

Has anyone implemented both in a Django project? Which would be more straightforward for maintaining a reliable donation system? Any advice on pros/cons of sticking with PayPal vs. switching to Stripe for this use case?

/r/django
https://redd.it/1fefwpv
how do you query a certain column without including it in the route's url?

Hey guys! I'll keep this concise,

Basically I'm trying to build a mini snowflake clone, and I have have this route which takes users to a SQL query interface for the worksheet they've selected (if you've used snowflake you'll know what I mean hahah).

@users.route("/<string:username>/query/<code>", methods='GET')
@loginrequired
def query(username, code):
    if username != current
user.username:
        abort(403)

    # what I currently have to do
    selectedworksheet = Worksheet.query.filterby(code=code)

    # what I'd like to be able to do
    selectedworksheet = Worksheet.query.getor404(worksheetid)

    # What I want to avoid doing as it seems to add the id to the url
    worksheetid = request.args.get('worksheetid', type=int)
    selectedworksheet = Worksheet.query.getor404(worksheetid)

    # remaining code ...


each worksheet has an id, but they also have a code so the url can look something

/r/flask
https://redd.it/1fexjlx
Thursday Daily Thread: Python Careers, Courses, and Furthering Education!

# Weekly Thread: Professional Use, Jobs, and Education 🏢

Welcome to this week's discussion on Python in the professional world! This is your spot to talk about job hunting, career growth, and educational resources in Python. Please note, this thread is not for recruitment.

---

## How it Works:

1. Career Talk: Discuss using Python in your job, or the job market for Python roles.
2. Education Q&A: Ask or answer questions about Python courses, certifications, and educational resources.
3. Workplace Chat: Share your experiences, challenges, or success stories about using Python professionally.

---

## Guidelines:

- This thread is not for recruitment. For job postings, please see r/PythonJobs or the recruitment thread in the sidebar.
- Keep discussions relevant to Python in the professional and educational context.

---

## Example Topics:

1. Career Paths: What kinds of roles are out there for Python developers?
2. Certifications: Are Python certifications worth it?
3. Course Recommendations: Any good advanced Python courses to recommend?
4. Workplace Tools: What Python libraries are indispensable in your professional work?
5. Interview Tips: What types of Python questions are commonly asked in interviews?

---

Let's help each other grow in our careers and education. Happy discussing! 🌟

/r/Python
https://redd.it/1fep0y6
Which Python libraries would be most suitable for Time Series Forecasts and Multilinear Regression?

I am working on a project geared towards addressing the issue of software project time estimation bias. To gather data, I'm building a work-log system that gathers info with respect to time taken to accomplish commonly-known tasks. These data will subsequently be trained using time series and multi linear regression.

Which Python libraries would be the most suitable for achieving these goals?

/r/Python
https://redd.it/1fexk8e
Help with ORM query

I have 3 models: Activity, ActivityDates and ActivityAttendies. Activity has a M2M relationship with ActivityDates and ActivityAttendies has a M2M relationship with ActivityDates.

class Activity(models.Model):
    FREQUENCY =
        ('Weekly', 'Weekly'),
        ('Monthly', 'Monthly')
   
    activitydates = models.ManyToManyField('ActivityDates')
    activity
name = models.CharField(maxlength=200)
    activity
interest = models.ForeignKey(Interest, ondelete=models.CASCADE)
    additional
activitydates = models.ManyToManyField('AdditionalActivityDates')
    activity
frequency = models.CharField(maxlength=11, choices=FREQUENCY, default=None)
    activity
location = models.CharField(maxlength=200)
    activity
cost = models.DecimalField(maxdigits=6, decimalplaces=2)
    activitystartdate = models.DateField(blank=True, null=True)
    activityenddate = models.DateField(blank=True, null=True)
    activityartwork = models.ImageField(uploadto='activityartwork', blank=True)

class ActivityDates(models.Model):
    activity
date = models.DateField()
    activityattendies = models.ManyToManyField(Person, relatedname='ActivityAttendies', through='ActivityAttendies', blank=True)
    activitystarttime = models.TimeField()
    activityendtime = models.TimeField()

class ActivityAttendies(models.Model):
 

/r/djangolearning
https://redd.it/1fexg7p
Do you have any ideas for simple Django tools?

hey all,

I decided to try my hand in creating simple tools for Django users. The first one I made is a Django Secret Generator (i know, there are many such sites out there, just trying something new, and learning django while doing it, some cur me some slack 🙈).

I'm planning to do a couple more. Here are some ideas I had:

Security checker (like, is admin page under /admin. I think there was one called django pony checker or something like that, but I'm not sure it still exists)
optimization checker (are your js and css files optimized)

I'm curious to hear from the community, if you have any ideas. Thanks a ton in advance.

/r/django
https://redd.it/1fezo43
Semantix : Make GenAI Functions easily

### What Semantix Does

Current methods for extracting structured outputs from LLMs often rely on libraries such as DSPy, OpenAI Structured Outputs, and Langchain JSON Schema. These libraries typically use Pydantic Models to create JSON schemas representing classes, enums, and types. However, this approach can be costly since many LLMs treat each element of the JSON schema (e.g., {}, :, "$") as separate tokens, leading to increased costs due to the numerous tokens present in JSON schemas.

Semantix offers a different and more cost-effective solution. Instead of using JSON schemas, Semantix represents classes, enums, and objects in a more textual manner, reducing the number of tokens and lowering inference costs. Additionally, Semantix leverages Python's built-in typing system with minor modifications to provide meaning to parameters, function signatures, classes, enums, and functions. This approach eliminates the need for unnecessary Pydantic models and various classes for different prompting methods. Semantix also makes it easy for developers to create GenAI-powered functions.

### Target Audience

Semantix is designed for developers who have worked with libraries like Langchain and DSPy and are tired of dealing with Pydantic models and JSON schemas. It is also ideal for those who want to add AI features to existing or new applications without

/r/IPython
https://redd.it/1ff2pi5
The a absolute high you get when you solve a coding problem.

2 years into my career that uses python. Cannot describe the high I get when solving a difficult coding problem after hours or days of dealing with it. I had to walk out one time and take a short walk due to the excitement.

Then again on the other side of that the absolute frustration feeling is awful haha.

/r/Python
https://redd.it/1ff847f
Welcome to our new moderators 🌈

Hi r/django, you might have noticed in the sub’s sidebar we have a lot of new moderators here. Welcome u/Educational-Bed-8524, u/starofthemoon1234, u/thibaudcolas, u/czue13, u/Prudent-Function-490 ❤️


We’re all members of the Django Software Foundation’s new social media working group launched earlier this year, and have decided to see where we could help with this subreddit. Some of us have pre-existing experience with Reddit, others not as much. We’ll do our best to make it work! We’re very invested in the health of the Django community in those kinds of social online spaces. That includes moderation per Django’s Code of Conduct but also hopefully helping promote things that are relevant to our community.


Thank you for having us! We’re also really interested in any and all feedback about the subreddit.

/r/django
https://redd.it/1ffew1d
Django E-commerce (Pharmacy Management): My Learning Project – Feedback Wanted!



I’m excited to share a project I’ve been working on as part of my journey to learn **Django**: **E-commerce** (Pharmacy Management) 🎉 This web application, built with **Django Rest Framework**

**Key Features:**

* 🔐 **User Authentication**
* 🛒 **Product Management**
* 🏪 **Pharmacy Management**
* 👤 **Profile Management**
* 📝 **Prescription Handling**
* 📦 **Order Management**
* 💳 **Secure Payments**
* 📂 **File Management**

**Technologies Used:**

* Django Rest Framework
* PostgreSQL
* Django Allauth, Simple JWT
* Swagger
* Docker, GitHub Actions, Nginx
* Dropbox for file management

**Hosting:**

* Deployed on **Azure** using **GitHub Actions** for continuous integration and deployment

**Github** [link](https://github.com/MohamedHamed12/E-commerce-Pharmacy-Back-End)

[https://github.com/MohamedHamed12/E-commerce-Pharmacy-Back-End](https://github.com/MohamedHamed12/E-commerce-Pharmacy-Back-End)

I’d love to hear any feedback or suggestions

/r/django
https://redd.it/1ff7btw
Friday Daily Thread: r/Python Meta and Free-Talk Fridays

# Weekly Thread: Meta Discussions and Free Talk Friday 🎙️

Welcome to Free Talk Friday on /r/Python! This is the place to discuss the r/Python community (meta discussions), Python news, projects, or anything else Python-related!

## How it Works:

1. Open Mic: Share your thoughts, questions, or anything you'd like related to Python or the community.
2. Community Pulse: Discuss what you feel is working well or what could be improved in the /r/python community.
3. News & Updates: Keep up-to-date with the latest in Python and share any news you find interesting.

## Guidelines:

All topics should be related to Python or the /r/python community.
Be respectful and follow Reddit's Code of Conduct.

## Example Topics:

1. New Python Release: What do you think about the new features in Python 3.11?
2. Community Events: Any Python meetups or webinars coming up?
3. Learning Resources: Found a great Python tutorial? Share it here!
4. Job Market: How has Python impacted your career?
5. Hot Takes: Got a controversial Python opinion? Let's hear it!
6. Community Ideas: Something you'd like to see us do? tell us.

Let's keep the conversation going. Happy discussing! 🌟

/r/Python
https://redd.it/1ffh7id
DBOS-Transact: An Ultra-Lightweight Durable Execution Library

**What my project does**

Want to share our brand new Python library providing ultra-lightweight durable execution.

https://github.com/dbos-inc/dbos-transact-py


Durable execution means your program is resilient to any failure. If it is ever interrupted or crashes, all your workflows will automatically resume from the last completed step. If you want to see durable execution in action, check out this demo app:

https://demo-widget-store.cloud.dbos.dev/

Or if you’re like me and want to skip straight to the Python decorators in action, here’s the demo app’s backend – an online store with reliability and correctness in just 200 LOC:

https://github.com/dbos-inc/dbos-demo-apps/blob/main/python/widget-store/widget_store/main.py

No matter how many times you try to crash it, it always resumes from exactly where it left off! And yes, that button really does crash the app.

Under the hood, this works by storing your program's execution state (which workflows are currently executing and which steps they've completed) in a Postgres database. So all you need to use it is a Postgres database to connect to—there's no need for a "workflow server." This approach is also incredibly fast, for example 25x faster than AWS Step Functions.

Some more cool features include:

* Scheduled jobs—run your workflows exactly-once per time interval, no more need for cron.
* Exactly-once event processing—use workflows

/r/Python
https://redd.it/1ff8257
Will there be any problem if I learn from a Django 4 Book?

I wanted to get into Django, and I already had a book laying around Django for Beginners: Build websites with Python & Django 4.0.

I saw that there was a newer version of this book that teaches with Django 5, should I get that book, or is my book good enough?

/r/djangolearning
https://redd.it/1ffa29n
Are celery jobs reliable?

Hey everyone,

I have a product that currently uses fastapi+sqlite3 to implement the mvp. I have a scheduled task in fastapi to do a few python things every hour. Currently, it's been working great for me.

Looking to scale up my project and just wondering if celery is a reliable solution. I'll probably be using cookiecutter-django since it's built in and should workfor this project, but just wondering if celery is the right choice for this. It's important that it runs every hour.

Any advice would be appreciated,
Thanks!

/r/django
https://redd.it/1ffma1e
Web platform to share and execute scripts...

Hi everyone, we are developing several scripts in my team for our colleagues and as of now we package them in .exe files. We would like to change approach: is there a way to share scripts internally in a much easier way? Is Flask a good option for doing this?Thanks.

/r/flask
https://redd.it/1ffo52b
MPPT: A Modern Python Package Template

**https://datahonor.com/mppt/**

Hey everyone, I wanted to introduce you to MPPT, a template repo for Python development that streamlines various aspects of the development process. Here are some of its key features:

# Package Management

Poetry
Alternative: Uv, PDM, Rye

# Documentation

Mkdocs with Material theme
Alternative: Sphinx

# Linters

Ruff
Black
Isort
Flake8
Mypy
SonarLint
Pre-commit

# Testing

Doctest
Pytest: pytest, pytest-cov, pytest-sugar
Hypothesis
Locust
Codecov

# Task runner

Makefile
Taskfile
Duty
Typer
Just

# Miscellaneous

Commits: Conventional Commits
Change Log: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
Versioning: Semantic Versioning
License: [Choose an open source license](https://choosealicense.com/)
Badge: Shields.io
Contributing: [Contributing to Open Source on GitHub](https://guides.github.com/activities/contributing-to-open-source/)
AI Reviewer: CodeRabbit

/r/Python
https://redd.it/1ffr5ku
maestro, a command-line music player

[https://github.com/PrajwalVandana/maestro-cli](https://github.com/PrajwalVandana/maestro-cli)

**What My Project Does**

maestro is a command-line tool written in Python to play music in the terminal. The idea is to provide everything you could possibly think of for your music experience in one place.

**Target Audience**

Anyone who listens to music!

**Comparison**

Lots of stuff that the big-name services don't have, such as tagging (instead of playlists), a built-in audio visualizer, free listen-along feature (think Spotify Jams), lyric romanization, listen statistics, etc. See the list of features below/in the repo for more!

Unfortunately, you *do* have to download your music to use `maestro`.

**Features**:

* cross-platform (obviously including Linux, that's why I posted it here lol)!
* someone got it working on their Linux phone?? crazy stuff
* add songs from YouTube, YouTube Music, or Spotify!
* stream your music!
* read the technical breakdown here: [https://github.com/PrajwalVandana/maestro-cli/blob/master/data/maestro\_listen\_along.pdf](https://github.com/PrajwalVandana/maestro-cli/blob/master/data/maestro_listen_along.pdf)
* lyrics!
* romanize foreign-language lyrics
* translate lyrics!
* clips! (you can define and play clips for a song rather than the entire song)
* filter by tags! (replacing the traditional playlist design)
* listen statistics! (by year and overall, can be filtered by tag, artist, album, etc.)
* shuffle! (along with precise control over the behavior of shuffling when repeating)
* also "bounded shuffle", i.e. a

/r/Python
https://redd.it/1ffiezv
pyrtls: rustls-based modern TLS for Python

What My Project Does

pyrtls is a new set of Python bindings for rustls, providing a secure, modern alternative to the venerable ssl module. I wanted to allow more people to benefit from the work we've done to build a better alternative to OpenSSL-backed TLS, and figured Python users might be interested.

https://github.com/djc/pyrtls

Target Audience

This is basically an MVP. While the underlying rustls project is mature, the bindings are fairly new and could contain bugs. I'd be happy to get feedback from people eager to try out something modern (and more secure).

Comparison

Unlike the ssl module (which dynamically links against OpenSSL), pyrtls is distributed as a set of statically compiled wheels for a whole bunch of platforms and Python versions. It is backed by Rust code, which is all memory-safe (except some core cryptography primitives), and avoids older protocol versions, insecure cipher suites, and risky protocol features. The API is intended to be similar enough to the ssl module that socket wrappers can act as a drop-in replacement.

/r/Python
https://redd.it/1ffwu5l
Whisper realtime hallucinations using Python...Open AI and .CPP models.

Does anyone have experience fixing hallucinations with Open AI Whisper and Whisper.cpp models when using realtime. All code is running via Python. Models tried from Tini to Large V3 both Open AI original models and .cpp verions for Metal.

Models are doing OK job with constant audio stream..however when audio hits silent (no one talking) or just mutes - then both Open AI and .cpp models seriously hallucinate by displaying "thank you, thank you, you, thank you....." and so on. none stop. Very annoing when you trying to put this to screen for monitoring.

Did some digging and so far no def answer on the fix (some tried and gave up)


Just checking if anyone has actually came across a fix. As specific parameters? not sure if for 3sec chunks VOD would be solution? or some kind of masking / filtering out?


Little lost on this, as: options: 1) Give up on whisper for this application 2) Is there actually a solution I am missing?


If anyone think they do have solution :) happy to pay for the correct answer if it fixes it!!


Thanks any way and all comments / suggestions are appreciated!

/r/Python
https://redd.it/1ffy7h6
Feature Friday: Django's Database-Generated Fields

Need DB-generated values in your Django models? Meet the new GeneratedField!
Define fields with values created by the database, not Django. This is powerful for computed columns & more.

DB-generated fields can be used for the following use cases:

- Computed columns
- Default values from DB functions
- Auto-updating timestamps

Here's a small sample code showing the usage of GeneratedField:

from django.db import models
from django.db.models import GeneratedField

class Product(models.Model):
name = models.CharField(max_length=100)
price = models.DecimalField(max_digits=10, decimal_places=2)
discounted_price = GeneratedField(
expression=models.F('price') * 0.9,
output_field=models.DecimalField(max_digits=10, decimal_places=2),
db_persist=True
)


Some benefits of the DB-generated Fields:

- Improved performance: calculations done at DB level
- Data consistency: ensures all apps see the same generated values
- Reduced code duplication: no need to replicate DB logic in Django

Learn more: https://docs.djangoproject.com/en/5.0/ref/models/fields/#generatedfield

Are you using this feature? Do you think it's useful?

Note: This post is part of a new "feature friday" initiative from the Django Social Media team to create awareness around some of Django's lesser-known and newer features. Let us know if you have any feedback!

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