Python Daily – Telegram
Python Daily
2.57K subscribers
1.49K photos
53 videos
2 files
39K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Is there an easy to use CI/CD solution for deployment? My usecase below.

As of now, I have a VPS on hetzner (I had it on Digital Ocean previously, but I migrated to hetzner).

I use apache to host it, all media files and static files along with database are hosted on the same VPS, and I have a bunch of cron jobs to run some background jobs...

As of now, I make changes locally, and push them, then ssh into the VPS, pull the changes, check permissions for each directory, restart apache and all the hassle...

I've also used Digital Ocean's app platform, so when I push to github, it will redeploy the project, but then, I'd to host the database and media files seperately, otherwise they will be gone after the re-deployment. Plus background tasks are pain, and the costs getting higher and higher.

I am looking for similar solution, but maybe somewhere else and not on Digital Ocean. Please suggest me the easiest options, or tricks to do the same on a VPS.

I really need some help.

Thank you very much..

/r/django
https://redd.it/1h4oaub
ComputeLite - A true serverless tool

What My Project Does:

ComputeLite is a true serverless tool that leverages the power of WebAssembly (WASM) and SQLite OPFS to ensure that all data and code remain securely in the browser, with no server dependencies or external storage. Right now it supports Python (powered by Pyodide) and SQL( powered by SQLITE)

So you can write all your python code and use Pyodide supported or pure python packages right away in browser without any need to install anything.

Target Audience:

Students, Developers, Could be used for noscripting

Comparison:

It can be compared with PyScript but user can create different models which could include noscripts with relative imports and packages listed in requirements.txt file

Link: https://computelite.com/

GitHub: https://github.com/computelite/computelite



/r/Python
https://redd.it/1h4spi7
Iris Templates: A Modern Python Templating Engine Inspired by Laravel Blade


What My Project Does

As a Python developer, I’ve always admired the elegance and power of Laravel’s Blade templating engine. Its intuitive syntax, flexible directives, and reusable components make crafting dynamic web pages seamless. Yet, when working on Python projects, I found myself longing for a templating system that offered the same simplicity and versatility. Existing solutions often felt clunky, overly complex, or just didn’t fit the bill for creating dynamic, reusable HTML structures.

That’s when Iris Templates was born—a lightweight, modern Python template engine inspired by Laravel Blade, tailored for Python developers who want speed, flexibility, and an intuitive way to build dynamic HTML.

# 🧐 Why I Developed Iris Templates (Comparison)

When developing Python web applications, I noticed a gap in templating solutions:

Jinja2 is great but can feel verbose for straightforward tasks.
Django templates are tied closely to the Django framework.
Many templating engines lack the modularity and extendability I needed for larger projects.

Iris Templates was created to bridge this gap. It's:

Framework-agnostic: Use it with FastAPI, Flask, or even standalone noscripts.
Developer-friendly: Intuitive syntax inspired by Blade for faster development.
Lightweight but Powerful: Built for efficiency without sacrificing flexibility.

# 🌟 Key Features of Iris Templates

1. "extends" and "section" for Layout Inheritance; Create a base layout and extend it effortlessly.
2.

/r/Python
https://redd.it/1h4zfnr
Best practice for autocomplete on a ModelChoiceField with ~10'000 entries

Dear Django community,

I am using the modern standard of Django + HTMX + Crispy. As part of a form, I would like the user to select one of 10'000 clients. The user should type in a few letters of either the first name or the last name and then get a dropdown of matching clients and be able to click on one of them.

So far, I explored and considered the following options:
1. I could build it from scratch in pure HTMX. Would work, but it's work traveling back and forth, doesn't seemingly integrate with the rest of my form and I'd need to travel to the backend for each letter the user types.

2. I could pass the entire client list to the frontend and do in Javanoscript, but I don't like to code stuff in javanoscript.

3. I implemented this video: django-crispy-forms & ModelChoiceFields / Select2 Integration for Searchable Form Fields, which does it as a standard Django field and then puts Select2 over it. However, the page load is too slow and I don't like the dependency on jquery.

4. I considered django-autocomplete-light, however, at first sight, it seems quite heavy with dependencies on multiple libraries. Further it

/r/django
https://redd.it/1h4zbyn
Best practice for self deployable open source Django project

Hi all,

I am working on a simple Django app for monitoring the progress of Snakemake workflows. For context, Snakemake is a workflow manager, largely targeted towards life sciences (bioinformatics, genomics, etc). It is run on the command line and currently lacks a good way to monitor the progress of your workflows (they can run for weeks in some cases).

I have experience building Django webapps and deploying them for myself. However with this, I would like to make the whole webapp a pip installable package such that users can just install via pip and spin up the server. This is extremely important, as in order for this to be a useful tool, the barrier to entry should be very low for users with little technical experience.

I have already worked out how the workflows will communicate with the running Django server. My general idea is this:

1. User starts the server
2. User starts snakemake workflow, gives server address
3. As workflow runs user can view progress on browser

Where I have questions is how to handle deployment and migrations:

1. For the database, I'll use sqlite since thats easy and I don't expect high traffic. I'm not sure how to apply migrations to a project

/r/django
https://redd.it/1h54h76
One-Click Deployment tool for Docker Apps (First Stable Release 0.2.0)

Hey Django devs! 👋

I'm excited to share Leverans, a deployment tool I've been working on that makes getting your apps online stupid simple. Here's why you might love it:

🚀 Key Features:

* Deploy ANY Docker-based app with a single command
* No vendor lock-in
* Works on minimal hardware (just 0.5 vCPU, 500 MB RAM)
* CLI-based with super simple config
* No need for SSH, external services, or complex setups

Why I built this: Deploying apps is a pain. Existing tools are either too complex or too restrictive. Leverans fixes that.

For example, this is all you need to describe a simple Django project:

\`\`\`yaml

project: django



apps:

main:

domain: [your-domain.com](http://your-domain.com)

port: 8000

volumes:

django-sqlite: /data

\`\`\`


And run the \`lev deploy\` command. And that's it, your application is online. On your own private VPS server.



Docs: [https://leverans.dev](https://leverans.dev)

GitHub Examples: [https://github.com/ethanhamilthon/leverans/tree/main/examples](https://github.com/ethanhamilthon/leverans/tree/main/examples)


This is v0.2.0 - our first stable release. Would love your feedback and a on GitHub if you find it useful!



/r/django
https://redd.it/1h50zfj
I don't know how set SECRET_KEY

Which of the two ways is correct?

SECRET_KEY = os.environ.get('SECRET_KEY') or 'myKey'

or

SECRET_KEY = os.environ.get('SECRET_KEY') or os.urandom(24)

/r/flask
https://redd.it/1h532hk
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/1h59v6z
Feedback for project creating conversational agents using a Finite State Machine (FSM) and LLMs

Hi r/Python community!

I've been working on a project combining Finite State Machines and Large Language Models.

What My Project Does
This project provides a framework for building conversational agents using a Finite State Machine (FSM) powered by LLMs like OpenAI GPT. It aims to create structured tools like step-by-step teaching systems, customer support bots, and multi-step memory games while addressing issues like hallucinations, loss of context, and unpredictability. I have a few example usages in the repo.

Target Audience
This is currently an experimental setup, and also part of a research project I am doing for university. For now it is meant for developers and experimenters mainly. Requires an OpenAI API key (currently tested on gpt-4o-mini).

Comparison
Unlike typical LLM-based chatbots, this combines FSM with LLMs to enforce structured, predictable conversations, making it ideal for use cases requiring adherence to predefined paths.

If anyone is interested I would love to hear your feedback and thoughts! The repo is here: https://github.com/jsz-05/LLM-State-Machine

Cheers!

/r/Python
https://redd.it/1h594wc
Building native Python desktop application with Pyloid and Gradio

Let's build a desktop chat application that streams responses from an LLM. We'll use three key libraries that work beautifully together:

- **[Pyloid](https://github.com/pyloid/pyloid)**: Creates native desktop applications -- like Electron but with Python
- **[Gradio](https://gradio.app)**: Builds the chat interface
- **[Promptic](https://github.com/knowsuchagency/promptic)**: Handles LLM interactions

Source Code: https://github.com/knowsuchagency/pyloid-chat-demo

## Prerequisites

Before running the application, you'll need:
- An OpenAI API key ([get one here](https://platform.openai.com/api-keys))
- [uv](https://github.com/astral-sh/uv) for Python package management
- [just](https://github.com/casey/just) command runner

## The Chat Interface

First, let's create the chat interface. This is where Gradio and Promptic work together:

```python
import gradio as gr
from promptic import llm

@llm(memory=True, stream=True)
def assistant(message):
"""{message}"""

def predict(message, history):
partial_message = ""
for chunk in assistant(message):
partial_message += str(chunk)
yield partial_message

with gr.ChatInterface(
fn=predict,
noscript="Chat Demo",
) as chat_interface:
chat_interface.chatbot.clear(assistant.clear)
```

The code above:
- Uses Promptic's `@llm` decorator to handle LLM interactions
- Implements streaming responses using a generator
- Creates a chat interface with Gradio
- By passing `memory=True`, Promptic will manage conversation history

## Making It a Desktop App

Now, let's wrap our chat interface in a native window using Pyloid:

```python
from pyloid import Pyloid
import threading
import time
import socket
from contextlib import contextmanager

HOST = "127.0.0.1"
PORT =

/r/Python
https://redd.it/1h5a26x
What's the cheapest way to host a python noscript?

Hello, I have a Python noscript that I need to run every minute. I came across PythonAnywhere, which costs about $5 per month for the first Tier Account.

Are there any cheaper alternatives to keep my noscript running? Would it be more cost-effective to run the noscript continuously by leaving my computer on? I’m new to this, so any advice or suggestions would be greatly appreciated. Thank you!

/r/Python
https://redd.it/1h5hikf
Are there any free hosting services for Django now?

ever since Heroku stopped offering free hosting for Django apps (RIP the GOAT), we've been left with very few good hosting services with free tiers. What is the current consensus for best free-tier hosting providers right now?

/r/django
https://redd.it/1h5ehet
Beginner Web App Deployment with Flask

I am looking to start hosting a web application of mine on an official web domain and need a little help. Right now, I have a full stack web application in JavaScript and Flask with a MySQL server. Currently, I run the website through ngrok with a free fake domain they create, but I am looking to buy a domain and run my app through that .com domain. I also have a Docker environment set up to run my app from an old computer of mine while I develop on my current laptop. What exactly would I need to run this website? I am thinking of buying the domain from porkbun or namecheap and then using GitHub and netlify to send my app code to the correct domain. Should I be using something with docker instead to deploy the app given I have a database/MySQL driven app? Should I use ngrok? Any help explaining what services and service providers I need to put in place between domain hosting and my Flask/JS app would be appreciated.

/r/flask
https://redd.it/1h53a3a
D Monthly Who's Hiring and Who wants to be Hired?

For Job Postings please use this template

>Hiring: [Location\], Salary:[\], [Remote | Relocation\], [Full Time | Contract | Part Time\] and [Brief overview, what you're looking for\]

For Those looking for jobs please use this template

>Want to be Hired: [Location\], Salary Expectation:[\], [Remote | Relocation\], [Full Time | Contract | Part Time\] Resume: [Link to resume\] and [Brief overview, what you're looking for\]

​

Please remember that this community is geared towards those with experience.

/r/MachineLearning
https://redd.it/1h3u444
Made a web platform using django over the last 6 months and loved it!

Coming from python background, django seemed like the perfect choice.

There was a lot of learning along the way. This was my first ever experience in web dev, coming from a large data science background.

I rebuilt over 4 times, and changed from end 3 times from not having all the foresights such as ssr for seo.

My final stack was nuxt/vue with django and postsql, jwt deployed on a digital ocean droplet.

Any questions I’d love to answer, it’s been quite the journey.

/r/django
https://redd.it/1h5s306
Adding multiple instances of the same product into cart

Hi guys, thanks for reading my post.
I'm currently making an Ecommerce website on Django that sells electronic devices for my university project. I chose Django as the primary framework since my teacher heavily emphasizes the interaction with databases.
Some clarification before I get to my question is that there are multiple instances of the same product stored within the database with all different IDs. For example, **If there are 5 "Laptop A"s, then all 5 of them must have different IDs**. So I've been having a lot of difficulty with the process of adding the products into the cart. Additionally, all products have attribute "Status" that indicates whether it's a new or secondhand product.
Suppose for my cart I currently have 10 instances of Laptop A.

7 of them are New and 3 of them are Secondhand.

class Product(models.Model):
id = models.IntegerField(db_column='ID', primary_key=True)
image = models.CharField(db_column='Image', max_length=255)
name = models.CharField(db_column='Name', max_length=255)
price = models.IntegerField(db_column='Price')
m_date = models.DateField(db_column='M_Date', verbose_name="Manufacture Date")


/r/django
https://redd.it/1h5n547
Fine-grained open source authorization solution (SDK for Python)

Hey, Python community! If anyone here is thinking about implementing authorization for RBAC / ABAC in your apps - feel free to check out our OSS solution: [https://github.com/cerbos/cerbos](https://github.com/cerbos/cerbos) 

It’s useful if you’re dealing with complex access control scenarios and fast-growing apps, where requirements are constantly changing.


**What My Project Does:** 
Cerbos PDP is an authorization solution that lets users define context-aware access control in simple, intuitive, and testable policies.  Some of Cerbos PDP’s key capabilities:

* Infinitely scalable RBAC and ABAC
* Plug-and-play & language-agnostic 
* Stateless design 
* Self-hosted
* Centralized audit logs of all authorization requests help compliance with ISO27001, SOC2, and HIPAA requirements


**Target Audience:**
Software developers working on building authorization for apps, AI agents, and AI companions.


**Comparison**
The most common alternative to externalized authorization is the “build it yourself” approach, hard-coded authorization. Here is how our approach is different:

* Our off-the-shelf solution allows you to avoid the technical debt and developer cost of hard-coded authorization.
* Having the separation of the permissions from the code base just makes the code and the permissions more elegant (no spaghetti code).
* Permissions are centralized, so they're not tied to specific endpoints. 
* Cerbos

/r/Python
https://redd.it/1h5v7n7
PyCon Austria 2025

PyCon Austria will take place on April 6 and 7, 2025 in Eisenstadt, Austria. The Call for Papers is already open, so you can submit your proposals for talks and workshops. Although registration is recommended for visitors, attendance is free of charge. The conference will start with an opening party on April 5, 2025.

Website with details, registration, and sponsor information: https://at.pycon.org

Call for Papers: https://www.papercall.io/pycon-austria

/r/Python
https://redd.it/1h5ubiu
PyBox: A Browser-Based Python IDE for Coding Anytime, Anywhere

What My Project Does
PyBox is a browser-based Python IDE designed for flexibility and accessibility. With it, you can:

Write, execute, and experiment with Python code directly in your browser—no installations required
Use an integrated Bash terminal for system-level noscripting.
Manage files with drag-and-drop and a file manager
Install and run packages
Visualize data using libraries like Matplotlib within the browser

Target Audience
PyBox can be useful for:

People experimenting with Python who want a simple, no-setup-required environment
Hobbyists or educators looking for a lightweight way to teach or experiment with Python code
Developers who occasionally need a quick and portable coding environment

It’s not built for large-scale production projects but works well for learning, prototyping, and noscripting

Comparison
The browser-based nature of PyBox sets it apart from traditional IDEs in several ways:

1. Portability: Since everything happens in the browser, PyBox works on any device—PCs, tablets, or even Chromebooks—without worrying about installations or configurations
2. Consistency: Whether you switch from one computer to another or use a public device, the coding environment remains consistent
3. Lightweight and Accessible: All you need is a browser. No downloading or installing tools, and no lengthy setup processes

It basically combines the accessibility of Replit with the

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