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
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
I wrote some flask code. Would anyone be willing to review the code I wrote. Everything works I just want to get someone opinion of the code. If yes I will private message you the code.

I wrote some flask code. Would anyone be willing to review the code I wrote. Everything works I just want to get someone opinion of the code. If yes I will private message you the code.

/r/flask
https://redd.it/1f3m6g7
Help designing model for including sem/year

I'm creating models to store questions and syllabus of different courses.

eg. program: Master of Fine Arts (MFA), courses: Sculpture, Visual arts

This is what I have in mind so far:

#django and postgresql
#from django.db import models

class Program(models.Model):
    programid = models.IntegerField(unique=True)
    program
code = models.CharField(maxlength=100)
    program
name = models.CharField(maxlength=100)


class Course(models.Model):
    course
id = models.IntegerField(unique=True)
    coursecode = models.CharField(maxlength=100)
    coursename = models.CharField(maxlength=100)
    coursecredit = models.IntegerField()
    course
icon = models.CharField(maxlength=50)
    program = models.ForeignKey(
        Program, on
delete=models.CASCADE, relatedname="courses"
    )

class Syllabus(models.Model):
    course = models.ForeignKey(Course, on
delete=models.CASCADE, relatedname='syllabus')
    topic = models.CharField(max
length=100)
    content = models.TextField()
    hours = models.IntegerField()
 

/r/django
https://redd.it/1f3robj
2023 Python Developers Survey Results

# 2023 Python Developers Survey

Results are in for the official Python Developers Survey, conducted in partnership with JetBrains!

The survey is a joint initiative between the Python Software Foundation and JetBrains.

Read more about it here.

/r/Python
https://redd.it/1f43acl
D Post any bginner questions to r/MLQuestions!

I have recently inherited the subreddit r/MLQuestions, as the other mods had been innactive for 10 months and 4 years respectively. I have been sprucing up the sub, adding flairs, rules, etc, and I am trying to increase engagement and make it more useful for those who want to ask questions. Basically, stackoverflow but dedicated to beginn\
r questions about ML. So if any of you have questions that your are too embarrased to ask here, ask at r/MLQuestions! I will also be introducing a system similar to r/changemyview, where each question someone answers, they get an increment to their user flair that shows how many questions they have answered!

BTW the mods gave me permission to post this, so thank you guys for this, very cool.

/r/MachineLearning
https://redd.it/1f3yfjg
How to add alt to img in django-summernote?

As title says. I am add blog post via admin panel. I have integrated django-summernote. I am not able to find any way to add alt tag to image uploaded inside post.

I followed this to integration https://djangocentral.com/integrating-summernote-in-django/

Thanks

/r/django
https://redd.it/1f48kyr
Fileuploads blocking Workers

Hello everybody,

I encountered a problem which got pretty big for my App now. Sometimes the app becomes unresponsive for a long time and will answer the request after like 50 seconds.

I think it is because a lot of users are uploading images and this blocks my gunicorn workers. Users might have a bad internet connection for example. Like this when 12 images are uploaded with bad connection and I only have 10 workers, this will cause a problem. (I also use Azure Blob Storage as my file storage)

How would you handle that?

Thank you in advance for your advice :)

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