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
Django project setup

Hello guys. I was wondering how a "professional" Django setup should be. I currently use the classical way through virtualenv and . requirements.txt. But I recently discovered pdm. It can also generate a template for Django projects. Is it a good idea? I also discovered poetry. What do you guys mostly use?

/r/django
https://redd.it/1f2lkl3
Showcase: Python AI Apps for Subtitles, Summarization, and Image Processing

Hello, Python community!

I’ve been learning about popular AI models and have created several Python apps leveraging them. I’d love to share my work and would greatly appreciate any feedback. Here’s a brief overview of each project:

# AutoSubs

What My Project Does:
AutoSubs is a web app that automatically generates subtitles for videos, allowing users to customize text styles, font types, sizes, and animation effects. The app also provides a quick manual review process to edit incorrect names or spellings.

Target Audience:
This tool is ideal for content creators, particularly those who produce YouTube Shorts or social media videos and need an efficient way to add subtitles.

Comparison:
Unlike other subtitle generators that offer limited styling options, AutoSubs emphasizes customization giving users greater control over the appearance of their subtitles.

# VideoSummarizer

What My Project Does:
VideoSummarizer is a web app designed to summarize YouTube videos. Users can input a YouTube URL and specify a word limit for the summary, which the app generates using natural language processing techniques.

Target Audience:
This tool is useful for anyone looking to quickly grasp the main points of a lengthy YouTube video, including students, researchers, and busy professionals.

Comparison:
While there are several video summarization

/r/Python
https://redd.it/1f2d7u9
flask-files

from flask import Flask

def Moscow(stor,okk):

try:
if 'add' in stor:
idad=stor.split(':')1
with open('adm.txt','a') as ado:
ado.write(f'{idad}\n')
return {"Good":"add admin"}



elif 'delet' in stor:
idele = stor.split(':')1
fileo = open('adm.txt','r').read()
if str(fileo) in str(idele):
eo = fileo.replace(idele,"")
with open('adm.txt','w') as wor:
wor.write(idele)
else:
return {"No":"ID IN Files"}

elif 'ofer' in stor:
op = open('adm.txt','r').read()
return op
except:
return {"Error"}

app = Flask(name)
@app.route('/<num>/stor=<text>')
def main(text,num):
try:
return Moscow(text,int(num))
except:
return {"BAD"}
if name == "main":

app.run(host='0.0.0.0', port=81)

/r/flask
https://redd.it/1f2um6j
How do you get users to login as bloggers?

So I'm a complete beginner and am making a blogging application as part of the mdn django tutorial. I know the django authentication basics, and have created a one-one relationship between a blogger model and users, but I have no idea how one restricts access to only those users with blogger models and allows users to register as bloggers.

/r/django
https://redd.it/1f2n9bc
PyPy 7.3.17 is out, with python2.7 and 3.10

https://pypy.org/posts/2024/08/pypy-v7317-release.html

A new RISCV backend, an updated REPL, faster and more complient with CPython. Give it a try. Works best on pure python codebases. PyPy really shines for simulations or other tasks with lots of python loops.

/r/Python
https://redd.it/1f34sxy
Flask-SocketIO: "Invalid async_mode specified" Error with Threading

Hi everyone,

I'm working on a project that uses Flask-SocketIO, and I'm running into an issue when trying to use threading as the async mode. My setup is as follows:

* I'm using Flask for my backend with Flask-SocketIO for real-time communication.
* My app requires the use of threading for certain operations, so I'm specifying `async_mode='threading'` in my SocketIO initialization.

However, I'm getting the following error when I try to run my app:

Traceback (most recent call last):
File "app.py", line 23, in <module>
socketio = SocketIO(app, cors_allowed_origins="*", async_mode='threading')
File "flask_socketio/__init__.py", line 187, in __init__
File "flask_socketio/__init__.py", line 243, in init_app
File "socketio/base_server.py", line 31, in __init__
File "engineio/base_server.py", line 81, in __init__
ValueError: Invalid async_mode specified
[PYI-2526802:ERROR] Failed to execute script 'app' due to unhandled exception!

I've tried a few things, including removing and reinstalling dependencies, but the error persists. From my understanding, Flask-SocketIO should support threading as an async mode. What am I missing here? Has anyone encountered this issue before and

/r/flask
https://redd.it/1f3b2vu
Improved QLineEdit for PyQt and PySide

Hey,

I wanted the QLineEdit to have an animated placeholder text that moves between inside and outside position depending on widget focus and text, so the placeholder is visible at all times while having a clean and modern look. I couldn't find any library for it so I made one.

Preview: https://github.com/user-attachments/assets/267832aa-44a3-4532-aca9-7e3b393e8a4b



What My Project Does:

It keeps every feature from the original QLineEdit and improves the placeholder text by animating it between two positions (inside and outside position). If the widget is not in focus and there is no input text, the placeholder is in the original (inside) position. If the widget is focused or has input text, the placeholder text moves to the outside, creating a gap in the border. This way the placeholder text is visible at all times.

The project can be used with PyQt5, PyQt6, PySide2, and PySide6, is completely customizable and easy to use. You can change the animation's duration and easing curve, the font used for the placeholder text (+ different sizes and colors depending on the position) and much more.

Target Audience:

It can be useful for anyone working with PyQt or PySide who wants to use a clean, modern and easy to use QLineEdit.

Comparison:

I couldn't find any library

/r/Python
https://redd.it/1f374p3
How can I start freelancing as a Django developer?

I have work on couple of Django projects and now feeling comfortable with my skills, just want to get advices and make friends with other Django developers.


/r/django
https://redd.it/1f38mbg
Broken Pipe Error using SQLAlchemy for Redshift connection

I am running a rather simple Flask App with the goal of displaying Redshift database tables to users of the App. The App User model is also stored as a database table in Redshift with usernames, id's etc. (not much security is needed for this so it's fine).

The app is deployed in a Docker container in [AWS ECS](https://aws.amazon.com/ecs/).

**The problem:**

Upon first deployment of the App everything works fine (login, accessing all routes, viewing the tables etc.). When i log out of the App with my user and close the browser and then try to login again a couple of hours later I get the following Error in my logs:

[2024-08-27 09:43:02 UTC]: LOG: Login attempt for user: user01
[2024-08-27 09:43:02 UTC]: LOG: Querying database for user01: user01/usr/local/lib/python3.9/dist-packages/sqlalchemy/engine/default.py:736: UserWarning: DB-API extension cursor.connection used
cursor.execute(statement, parameters)
[2024-08-27 09:43:02 UTC]: LOG: Error querying database for user user01: (redshift_connector.error.InterfaceError) BrokenPipe: server socket closed. Please check that client side networking configurations such as Proxies, firewalls, VPN, etc. are not affecting your network connection.

(Background on this error at: https://sqlalche.me/e/14/rvf5)
[2024-08-27 09:43:02 UTC]: SQLAlchemyError occurred:

/r/flask
https://redd.it/1f2f753
problem routing the urls for my django ninja api

from .models import Order, OrderItem
from ninja import Router,NinjaAPI
from django.shortcuts import getobjector404
from ninja import Schema
from products.models import Product

api = NinjaAPI()
router = Router()

class OrderSchema(Schema):
    id: int
    user
id: int
    products: listint
    totalprice: int
    shipping
address: str
    createdat: str
    updated
at: str
    ordernumber: str

class OrderCreateSchema(Schema):
    products:list[int]
    total
price:int
    status:str

# list

router.get("/orders/", response=listOrderSchema)
def listorders(request):
    order = Order.objects.all()
    return order

@router.get("/orders/{orderid}/", response=OrderSchema)
def getorder(request, orderid:int):


/r/djangolearning
https://redd.it/1f2o6hc
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/1f3ojlk
Documentation difficult to navigate

I find Django documentation VERY annoying to navigate. Everything seems to be explained "by example" and actual reference overviews are hard to find. I feel like the documentation reads like one long tutorial on everything that Django has, but it leaves out many details that I would want to know, as I really don't like much "magic" happening in my code and the Django framework itself already introduces enough of that.

For example, the IntegerChoices class of Django models: I can't find it through the search bar, it is NOT in the General Index, but it is mentioned in the examples in the IntegerFields documentation under enumeration types. How would I have been able to find this if I encountered this class and wanted to look it up? Visit every possible related page and ctrl+F?

I just want to see for every class an overview of its member functions, what goes in, what comes out and which type everything is supposed to be in an exact, unambiguous way, like most other documentation of anything else ever. I don't want to read a book when I quickly want to find something...

Am I the only one annoyed

/r/django
https://redd.it/1f39njx
Anaconda Blues anyone else?

Despite the post here from 4 years ago, looks like Anaconda is going shopping for revenue from unsuspecting companies. We are a non profit that happens to have various solutions that leverage anaconda. Wondering if anyone has been through this and what their results were?



/r/Python
https://redd.it/1f3mfsk
Python Zen and implications

I was encouraged to reconsider my understanding the true implications of some of the Python Zen design principles, and started questioning my beliefs.

In particular "Explicit is better than implicit". Pretty much all the examples are dead-trivial, like avoid "import *" and name your functions "read_something" instead of just "read".

Is this really it? Has anyone a good coding example or pattern that shows when explicit vs. implicit is actually relevant?

(It feels that like most of the cheap Zen quotes that are online, in which the actual meaning is created "at runtime" by the reader, leaving a lot of room for contradictory interpretations)

/r/Python
https://redd.it/1f3pbet
Has Anyone Used Lemon Squeezy with an HTML Django Project?

I'm looking to integrate Lemon Squeezy into my HTML Django project and was wondering if anyone here has experience with it. How well does it work, and are there any tips or best practices you can share? Any insights or advice would be really helpful!

/r/django
https://redd.it/1f3vdqq
We just open sourced! Launch websites, APIs, and workers to AWS / GCP with Python

Hey everyone, my team and I spent the last 6 months refactoring our DevOps platform into an open source deployment tool for AWS / GCP - LaunchFlow.

GitHub repo: https://github.com/launchflow/launchflow

Docs: https://docs.launchflow.com/

What My Project Does

The Python SDK lets you launch websites, APIs, and workers to AWS / GCP with minimal configuration—no messy YAML required.

Networking, permissions, and other environment configurations are automatically handled for you. It only takes one line of code to deploy static sites, serverless APIs, managed Postgres, Kubernetes clusters, and more.

Target Audience:

Developers building on AWS / GCP.

LaunchFlow is not just for deploying Python applications.

The Python SDK is used to define your infrastructure in code, but you can deploy any static or Dockerized application to AWS or GCP.

Python is just the language for your cloud configuration, similar to how Terraform uses HCL.

Comparison:

LaunchFlow is most commonly compared to CDK for Terraform and Pulumi.

LaunchFlow is a higher-level abstraction than both of these tools. It provides a more opinionated way to define your infrastructure and handles things like networking, security, and environment management out of the box.

We’re also going much deeper on “deployments” than other IaC tools do. Terraform / Pulumi are typically paired with a separate deployment tool, whereas LaunchFlow combines release management with the

/r/Python
https://redd.it/1f3hexb
Seeking Advice: Building a Web App as a Data Engineer

I'm a data engineer who would like to gain some experience in front-end development. I'm getting frustrated not being able to represent the data we store in the database to the user.

To gain experience, I would like to build a web app to track my investments, similar to the image attached. I have good exposure to JavaScript and I'm currently learning React, as well as Python.

My question is: Should I use Django for this project or go with full JavaScript using React? I'm quite new to web development. Based on my research, it seems that Django would mainly be useful for creating an API for the front-end to use. If that's the case, I might opt for FastAPI since it has less boilerplate.

Anyway, I'm a bit lost and unsure of what I should do.

Thanks for your help!



Dashboard example



/r/django
https://redd.it/1f3yv0u
Building a Custom Paint Store: Time and Cost Estimation for Advanced Color Matching API Development

https://preview.redd.it/2609503u0lld1.png?width=1280&format=png&auto=webp&s=dd1d3d37e597ea224ae26fd73b342bebed70cbd3

https://preview.redd.it/u4ybjkou0lld1.png?width=420&format=png&auto=webp&s=f8287bb1588e09b485532817698637c8a11b7eeb


I'm developing a website for selling construction paints. For the past two weeks, I've been working with an assistant to create a color palette like the one in the first screenshot. We've also implemented a color input field that checks both our color palette and the palettes of competitors (everything is legal, it's just to ensure the correct spelling of color names and numbers from other companies, in case a customer wants our paint but with a color from another brand, without any trademark or copyright issues). This is the basic functionality we have right now.

Here's the new functionality described in the third screenshot (which I photoshopped for now):

1. Implement a color search feature.
2. Display similar colors.
3. Show the selected color and a room in that color.
4. Below that, display other room options. When a user clicks on a room, they will see it in the selected color (the image won't be pre-prepared; the room will be recolored in the selected color using code, and the recolored room image will be saved. There will be 8,000-10,000 colors and 6-8 room images).
5. Add the ability for users to upload their own room images, select walls, and have them recolored

/r/Python
https://redd.it/1f3z83t
is learning flask in Canada worth it?

Here are the job openings in the area near me. php =600 django=111 flask=76 .net=2000 spring=287 springboot=492 node=1.200 ruby=292 ROR=328 go=470

It kind of discourages me from learning flask, is flask growing in job openings or will go start to eat away at its market share?

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