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
Postgres VS MySQL?

Hello,

I came from PHP (Laravel) world and started to work with python and django only several months ago.

Since then, I see that PostgreSQL is much more popular than MySQL in django world. Are there any reasons for it beside of historic ones?

Should I switch my choice of DB to postgres or I can stay with mysql?

/r/django
https://redd.it/1e3ek6c
Qt (PySide6) or a Flask app running in a window for a modern, fluid desktop application?

(I know I'll probably get biased answers here, but you never know. You guys also might know something I don't yet that could influence my choice.)

Greetings.

To provide some context, I'm a 17-year-old intern at a very small startup -- so small that there are no adult employees, save for the founder and his son. The founder, our boss, was our AP Computer Science teacher (AP is an American program that allows high school students to learn college credit by taking a class and subsequent exam on content equivalent to an entry-level college course). He needed some help, so he offered unpaid internships to a few of us.

Anyway, my first task is to find a Python UI library. The founder is very adamant about using Python for this application -- I guess for its host of APIs and junk. (It's an application whose main functionality is a chatbot powered by the OpenAI API. I don't feel comfortable sharing any more details.) And, well, for a practical, modern, fluid, and responsive UI, I came to two options: PySide6, for its features; or Flask, for the ease-of-use of HTML, CSS, and JS, as well as Flask's simplicity, with a library to run a window in

/r/flask
https://redd.it/1e3htvw
Monday Daily Thread: Project ideas!

# Weekly Thread: Project Ideas 💡

Welcome to our weekly Project Ideas thread! Whether you're a newbie looking for a first project or an expert seeking a new challenge, this is the place for you.

## How it Works:

1. **Suggest a Project**: Comment your project idea—be it beginner-friendly or advanced.
2. **Build & Share**: If you complete a project, reply to the original comment, share your experience, and attach your source code.
3. **Explore**: Looking for ideas? Check out Al Sweigart's ["The Big Book of Small Python Projects"](https://www.amazon.com/Big-Book-Small-Python-Programming/dp/1718501242) for inspiration.

## Guidelines:

* Clearly state the difficulty level.
* Provide a brief description and, if possible, outline the tech stack.
* Feel free to link to tutorials or resources that might help.

# Example Submissions:

## Project Idea: Chatbot

**Difficulty**: Intermediate

**Tech Stack**: Python, NLP, Flask/FastAPI/Litestar

**Description**: Create a chatbot that can answer FAQs for a website.

**Resources**: [Building a Chatbot with Python](https://www.youtube.com/watch?v=a37BL0stIuM)

# Project Idea: Weather Dashboard

**Difficulty**: Beginner

**Tech Stack**: HTML, CSS, JavaScript, API

**Description**: Build a dashboard that displays real-time weather information using a weather API.

**Resources**: [Weather API Tutorial](https://www.youtube.com/watch?v=9P5MY_2i7K8)

## Project Idea: File Organizer

**Difficulty**: Beginner

**Tech Stack**: Python, File I/O

**Description**: Create a script that organizes files in a directory into sub-folders based on file type.

**Resources**: [Automate the Boring Stuff: Organizing Files](https://automatetheboringstuff.com/2e/chapter9/)

Let's help each other grow. Happy

/r/Python
https://redd.it/1e3gu3z
What's the best way to mask auto-incrementing id field from end users? (read full post)

I've been using django-hashid-field for quite to mask the id field from frontend. The primary reason I am using that was

- I don't want to generate and store UUIDs in database column separately.
- I don't want to expose Auto-incrementing Primary keys to the end users.

Now the django-hashid-field package is retired, they recommend that everyone start using django-sqids.

Has anyone started using django-sqids in production? Are there any better alternatives?



/r/django
https://redd.it/1e3nrik
Take a look at the onclick function in html. First picture is from firefox and the second one is the code. Can anyone explain where those quotation marks come from? If I delete those spaces in my .html file even more funny stuff happens. I'm happy to share more code if needed.

https://redd.it/1e3eecy
@pythondaily
Maker-checker in Django Admin

Has anyone implemented a Maker-Checker in django Admin??
I can't find any materials for it so any help would be great. So basically, I need to implement a maker-checker to the models in django admin. Every Add, Edit, or Delete must go through an Admin Approval first. But an admin cannot approve their own request. Another Admin must do it.

I'm having a hard time implementing it. So far I managed to somehow make it work in a user Model but the password is not being saved when approving a create user request. And in Groups, I can't approve a create group request because of an error like Group: Group_name needs to have a value field "id" before this many-to-many relationship can be used

/r/django
https://redd.it/1e3plp1
File Submission App defaulting to "true" condition for IF statement and not loading index

Hi everyone. I'm working my way through learning flash and trying to build out a basic program that prompts the user to submit a file, then do something with it, and then spit it back out.

Currently there is basic HTML and CSS. The problem is that the Flask app defaults to the "true" condition that a file has been uploaded and returns my "File Saved" automatically on running flask. It should return my index.html based on my script (i think). I've tried commenting out/removing sections but I can't seem to get the index.html to appear without just returning it above the conditional statements... and losing out on the script altogether. I know I must be missing something simple but my magic duck is nowhere to be found... Thanks for your help!

index.html

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Flask App</title>
    <link rel="stylesheet" href="static\style.css">
</head>

<body style="padding: 15px; background-color: aliceblue";>


/r/flask
https://redd.it/1e2za09
Deploying Django in the cloud

Hello all,

I’m coming from Laravel, huge fan of Django so far, love the simplicity of the ORM in particular (using DRF).

One thing I have not found yet is an equivalent to Laravel Forge: a service to deploy in an easy, streamlined, reliable manner, for which I am ok to pay, if possible agnostic in terms of cloud provider (but likely to use AWS).

What do you guys use or recommend?

/r/django
https://redd.it/1e3swff
I've made a module to go-to-definition of given objects

I'm using notebooks in Visual Studio and didn't have a working go-to-definition function, so I made a function srcview.open which opens the source for a given object in your EDITOR.

It should also work on any local interactive shell environment.

just %pip install srcview, and srcview.open anything you want :)

Feedback and suggestions are most welcome!

/r/IPython
https://redd.it/1e3u7ez
betterconf: minimalistic Python library for your configs.

betterconf (better config) is a Python library for project configuration management.

# What my project does

It allows you define your config like a regular Python class, casting values, getting values from anywhere and anyhow.

# Features and drawbacks

betterconf is really lightweight: all you need is Python >=3.8, no other dependencies. betterconf has simple, easy-to-learn API, which'll give you no struggle. betterconf's API is rich, staying as simple as possible, giving you lots of tools. betterconf is fully covered by tests so it won't fall by unexpected reason.

But as anything it has its own drawbacks.

By default there is a support only for os.environ. Any other providers like .json, .toml and everything else is not included but really easy to write due to betterconf's rich documentation.

betterconf doesn't have any security features or anything, but they could be easy added by a user.

# Audience

betterconf is fully production-ready, available as on PyPi so on GitHub. It can be used at web APIs, CLI tools, bots, everything...

# Comparison

Betterconf is simple and not sophisticated. Other libraries can have deep features that betterconf doesn't, but in exchange it gives you an ability to code it yourself. So, betterconf is ultimately-pluggable.

Code example:

from betterconf import Config, field


/r/Python
https://redd.it/1e3fojy
I am getting this error ModuleNotFound: No module named flask_mysqldb

I already tryed pip install flask-mysqldb and pip3 install flask-mysqldb I am using a mac and I am trying to install it on python virtual environment and I also tryed to install mysqlclient but nothing works

/r/flask
https://redd.it/1e3x2d5
I made GestureFlow to improve my productivity!


# What My Project Does

GestureFlow is an innovative application that enhances the traditional right-click functionality on computers by introducing a customizable radial menu. Here's what it does:

1. Radial Menu Activation: When you hold the right mouse button for a short duration (200ms), a circular menu appears around your cursor.
2. Quick Action Selection: Move your mouse in the direction of the desired action and release the button to execute it. No need for precise clicking on small menu items.
3. Customizable Actions: The menu includes common actions like Copy, Paste, Undo, Redo, and more. These can be easily customized or expanded in the code.
4. Visual Feedback: The menu provides clear visual feedback with hover effects and color changes, making it intuitive to use.
5. Cross-Platform Compatibility: GestureFlow works on both Windows and macOS, automatically adjusting its keyboard shortcuts for each platform.
6. Efficient Workflow: By combining multiple actions (e.g., "Select All + Copy"), it reduces the number of steps needed for common tasks.

# Target Audience

GestureFlow is designed for:

1. Power Users: Individuals who value efficiency and customization in their daily computer use.
2. Professionals: Developers, designers, writers, or anyone who frequently uses context-based actions in various applications.
3. Accessibility Enthusiasts: People interested in alternative input methods that

/r/Python
https://redd.it/1e3jye6
D Simple Questions Thread

Please post your questions here instead of creating a new thread. Encourage others who create new posts for questions to post here instead!

Thread will stay alive until next one so keep posting after the date in the title.

Thanks to everyone for answering questions in the previous thread!

/r/MachineLearning
https://redd.it/1e34cwr
OpenSkill MMR Rating System Now Features Per Player Weights

What My Project Does

OpenSkill is a peer-reviewed multiplayer ranking and rating system you can use to implement matchmaking systems on top of. This rating system behaves "like" TrueSkill, but is full open source, and unencumbered by patents, or trademarks. TrueSkill (Microsoft's proprietary, and patented rating system), has had something similar to this feature called "partial-play" for a while now. Our implementation is fully typed, supports pypy, and cpython and has 100% test coverage.

So what's this new change? Well there are not many open source rating systems (at least that I'm aware of) that let you consider in-game player scores to be factored into the rating updates. Only got 1 kill while the rest of your teammates got 4 or 5 kills? The rating system will update it's beliefs about a player based on these metrics. This means faster convergence to your actual skill.

Target Audience

I hope this new feature is useful to the game development community, especially those making multiplayer games. There is a lack of support for the game development ecosystem in Python. So here's hoping, your next multiplayer game finds use of this project!

Comparison

Some alternatives include EloMMR, Glicko-2 and TrueSkill. All of these are lacking in some areas.

GitHub Source

/r/Python
https://redd.it/1e42ds7
Django devops without Kubernetes

I'm not trying to use Kubernetes and AWS EKS. They're too overkill for my current project. How can I deploy without downtime while not using Kubernetes? I want to avoid deployment downtime at all cost.

/r/django
https://redd.it/1e408bc
Docker for Flask

I have been trying to look for online solutions and practices followed but generally they do it for the flask template app which does not cover the cases for real-world large scale applications. I personally have worked on numerous flask applications but while deploying am never successful in actually implementing the Dockerfile. Kindly guide me on how to tackle this.

/r/flask
https://redd.it/1e42cx3
Unable to type texts to chatbot user input

Hey guys, first time posting here. I am trying to add a chatbot for the backtesting platform built with Flask and there is a button on the right side that toggles the sidebar. If the user clicks the button, it shows the sidebar with a chatbot. But I'm going through an unexpected bug and would be utterly grateful if you guys could help me out.

I'll add this link(https://stackoverflow.com/questions/78752558/unable-to-type-texts-to-chatbot-user-input) that I posted on StackOverflow with the HTML, CSS, JS codes, and app.py code.

# Expected Behavior

The user should be able to type texts into the chatbot user input field.

# Current Behavior

Currently unable to type texts into the chatbot user input field.

https://preview.redd.it/l8l04x804tcd1.png?width=1914&format=png&auto=webp&s=81080e4a4efb536d9a9a4c9c9a29ff4f56082a63

/r/flask
https://redd.it/1e4fj86
Is SQLAlchemy really that good?

I've read a lot about SQLAlchemy and it seems to get a lot of hate for bad documentation or poor performance. I heard Peewee is a good alternative that's much more optimized and easier to use. The question is though, why is SQLAlchemy still so popular and widely used in industry? I heard it's the go-to for startups who choose Flask for their projects.
Personally I work with raw SQL queries The only advantage of SQLAlchemy I can sense is when defining tables and data, it's much easier to make the change, while with raw queries, you must modify each query string statement individually. For projects that use many tables with tons of columns that might be exhausting. But if the performance concerns are true, how does SQLAlchemy get away with it?



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