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
Flask wont serve audio on iOS

Hey guys,


I made a translator app and it uses elevenlabs to generate tts, but for some reason it wont serve the audio to my iphone, but works literally everywhere else.


Please help!

thanksss

/r/flask
https://redd.it/1e874k8
Iโ€™m thrilled to announce the release of my new Django package

๐Ÿš€ Introducing Django Data Seed: Your Solution for Database Test Data! ๐Ÿš€Iโ€™m thrilled to announce the release of my new Django package, Django Data Seed! ๐ŸŽ‰

This tool is designed to make the lives of developers easier by simplifying the process of populating databases with test data. Whether youโ€™re working on a small project or a large-scale application, Django Data Seed helps you quickly generate realistic data for your development and testing needs.

With Django Data Seed, you can efficiently manage and populate your database with just a single command. It's perfect for ensuring that your applications are rigorously tested and ready for production.

I invite you to check out Django Data Seed on PyPI and GitHub:
๐Ÿ”— PyPI: https://pypi.org/project/django-data-seed/
๐Ÿ”— GitHub: https://github.com/rohith-baggam/django-data-seed
๐Ÿ”— Linkedin : https://www.linkedin.com/in/rohith-raj-baggam/

Thank you for your support, and I look forward to seeing how Django Data Seed can help streamline your development process! Keep an eye on the PyPI package for exciting new features in upcoming versions.

u/django u/python u/backenddevelopment u/djangoorms

/r/Python
https://redd.it/1e8e3hh
Activation Email

I am new to django and was working on a project and got to this error while I was trying to build the auth system. I tried to send a activation email to the mail in the registerd field but got this error in a file called app_settings.py it is related to the allauth package.


Traceback (most recent call last):

File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1045, in _bootstrap_inner

self.run()

File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 982, in run

self._target(*self._args, **self._kwargs)

File "/Users/Adwait/.local/share/virtualenvs/game_advisior-8eIvWGTq/lib/python3.11/site-packages/django/utils/autoreload.py", line 64, in wrapper

fn(*args, **kwargs)

File "/Users/Adwait/.local/share/virtualenvs/game_advisior-8eIvWGTq/lib/python3.11/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run

autoreload.raise_last_exception()

File "/Users/Adwait/.local/share/virtualenvs/game_advisior-8eIvWGTq/lib/python3.11/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception

raise _exception[1\]

File "/Users/Adwait/.local/share/virtualenvs/game_advisior-8eIvWGTq/lib/python3.11/site-packages/django/core/management/__init__.py", line 394, in execute

autoreload.check_errors(django.setup)()

File "/Users/Adwait/.local/share/virtualenvs/game_advisior-8eIvWGTq/lib/python3.11/site-packages/django/utils/autoreload.py", line 64, in wrapper

fn(*args, **kwargs)

File "/Users/Adwait/.local/share/virtualenvs/game_advisior-8eIvWGTq/lib/python3.11/site-packages/django/__init__.py", line 24, in setup

apps.populate(settings.INSTALLED_APPS)

File "/Users/Adwait/.local/share/virtualenvs/game_advisior-8eIvWGTq/lib/python3.11/site-packages/django/apps/registry.py", line 116, in populate

app_config.import_models()

File "/Users/Adwait/.local/share/virtualenvs/game_advisior-8eIvWGTq/lib/python3.11/site-packages/django/apps/config.py", line 269, in import_models

self.models_module = import_module(models_module_name)

\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^

File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module

return _bootstrap._gcd_import(name[level:\], package, level)

\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^

File "<frozen importlib._bootstrap>", line 1204, in _gcd_import

File "<frozen importlib._bootstrap>", line 1176, in _find_and_load

File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked

File "<frozen importlib._bootstrap>", line 690, in _load_unlocked

File "<frozen importlib._bootstrap_external>", line 940, in exec_module

File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed

File "/Users/Adwait/.local/share/virtualenvs/game_advisior-8eIvWGTq/lib/python3.11/site-packages/allauth/account/models.py", line

/r/django
https://redd.it/1e7xsj8
Extracting data from (tricky) PDFs for Excel using Python (both API and DIY)

Hey Python learners, I'd like to share how to use AI (specifically Google's new Gemini model) to extract structured data into a CSV/XLSX format from PDFs.

I'm sharing this because most traditional solutions that don't use AI seem to fail for very complicated PDFs.

These docs covers how to do this entirely with an API, and the API github linked in the guide has further instructions on how you can do this whole process for yourself with Python with an LLM provider.

Have fun!

/r/Python
https://redd.it/1e8m8l2
odex - python object index for fast, declarative retrieval

# What My Project Does

Odex provides a set-like collection called `IndexedSet` which allows for fast, declarative queries on native python objects:

from odex import IndexedSet, attr, and_

class X:
def __init__(self, a, b):
self.a = a
self.b = b

iset = IndexedSet(
[
X(a=1, b=4),
X(a=2, b=5),
X(a=2, b=6),
X(a=3, b=7),
],
indexes=["a"]
)

# Filter objects with SQL-like expressions:
iset.filter("a = 2 AND b = 5") == {X(a=2, b=5)}



/r/Python
https://redd.it/1e8o4jg
Pilgram, a texting based idle MMO RPG

Pilgram is a telegram bot entirely built in python that lets you play a grimdark idle MMO RPG powered by AI.

In Pilgram you can go on endless quests, fight endless monsters, craft powerful artifacts, cast spells, join guilds & cults, find powerful loot & become the ultimate adventurer!

# What my project does

The bot provides a text interface with wich you can play an endless online idle loot based adventure game

# Target audience

RPG players will probably like it. It's a toy project that i initially made out of boredom, also it sounded cool. I kept developing it after it got a small community by adding requested features like guild taxes, combat & loot.

# Comparison

The game is kind of similar to a MUD (Multi User Dungeon) but it has idle game elements & Diablo style loot generation.

# More info

How is it infinite? The secret is AI. Every quest, event, monster & artifact in the game is generated by AI depending on the demand of the players, so in practice you'll never run out of new stuff to see.

The interface is exclusively text based, but the command interpreter i wrote is pretty easy to integrate in other places, even in GUIs if

/r/Python
https://redd.it/1e8pt2b
Wrote some absolutely atrocious code and Im kinda proud of it.

In a project I was working on I needed to take out a username from a facebook link. Say the input is: "https://www.facebook.com/some.username/" the output should be a string: "some.username". Whats funny is this is genuinely the first idea I came up with when faced with this problem.


Without further a do here is my code:

def get_username(url):
return url[::-1][1 : url[::-1].find("/", 1)][::-1]



I know.
its bad.




/r/Python
https://redd.it/1e8p16u
500+ Python Questions Quiz

Compiled 500+ Python questions into a quiz. I'm trying to improve my understanding of Python so this was helpful.

Quiz

I'll keep refining the questions to make sure it covers all the important topics in Python.

If you come across a question whose answer you doubt, please leave a comment and I'll check it again. Any recommendations or changes, please let me know.

So what's your score?

PS. This was built for Applyre users, who might want to use it for interview prep.

/r/Python
https://redd.it/1e8ry4p
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/1e90f3e
I created a script that predicts Premier League football (soccer) results

Hi everyone,

I had a script that I made a while ago to predict football (soccer) results in the Premier League, and I've just made it into a webpage so everyone can use it.

Page: https://jimmyrustles.pythonanywhere.com/football

Github: https://github.com/sgriffin53/footballpredictorflask

It uses a Gaussian Naive Bayes model to predict results based on past data. It uses the data from the 2021-2024 seasons.

What My Project Does

It shows predictions for the next 30 days of football matches in the Premier League with predictions for scores for each match. The predictions are based on a probability model based on past performance. You can also input custom teams to see what the result would be in a match between them.

Target Audience (e.g., Is it meant for production, just a toy project, etc.

This is originally just for myself and my friend Jay. We've been using it to place accumulators on Premier League matches based on the predictions, only small longshot bets that would result in big payouts. We haven't won any money, but the bot has got a few 1 - 0 and 0 - 0 results correct in the time we've been using it. I made it into a Flask page so that everyone can use the predictions. It's intended

/r/Python
https://redd.it/1e8ym80
Help: I am new to Django and I feel lost

I want to progress in my Python programming using Django. I feel stuck because I don't know where to source learning materials and there aren't many Django lovers where I am coming from and YouTube didn't offer much help.
I would appreciate it if I could get help and ideas here

/r/django
https://redd.it/1e90dax
Protean - Opensource DDD/CQRS/ES Python Framework

**Protean is an open-source Python framework designed to build ambitious applications that scale and evolve.**

Sourcecode: [https://github.com/proteanhq/protean/](https://github.com/proteanhq/protean/)

Documentation is under construction and available at [https://docs.proteanhq.com/](https://docs.proteanhq.com/).

# What My Project Does

**Protean offers CQRS and Event-Sourcing tools and patterns for creating sustainable, domain-driven codebases.** It aims to tackle complexity in high-stakes domains and keep the codebase sustainable and maintainable.

At its core, Protean adopts a Domain-Driven Design (DDD) approach to development, supporting patterns to succinctly and precisely express your domain.

A Protean domain model sits at the center of the application. Infrastructure concerns like ORMs, API frameworks, and message brokers are plugged into it via configuration.

Protean has a ports-and-adapters architecture. When ready, developers can seamlessly plug technologies like databases, message brokers, and caches, and Protean will take care of the rest.

# Comparison

Protean is an alternative to Django but without the constraints that come with a monolithic system or full-stack frameworks. One can start with one domain hosted as one service but fragment the domain into multiple bounded contexts over time, deployed as microservices. Each piece of technology/infrastructure can be plugged in or swapped out with configuration.

# Target Audience

Protean is an ideal framework for:

* **Startups**: because they start small and want to get to market fast, and still want

/r/Python
https://redd.it/1e8v29e
Want to contribute and learn from some django based mid sized projects.

I have been working in django DRF and react for couple of years. I hvae used vultr and aws for the deployments. However I am interestd to see how mid size projects are organized where there are more than 5-6 devs working on the same project. Would love to know if there is any open source project or if anyone want to let me see how they organize their code.

/r/django
https://redd.it/1e95rkk
AWS EC2 Auto Scaling vs AWS ECS Fargate for Django

Which one would be more suitable for a site that has 2000 active users? and how much would it cost to use EC2 Auto Scaling vs ECS Fargate? please share your experience. I'm using Supbase database.

/r/django
https://redd.it/1e95eq4
no able to log-in after migration

hey guys, i have a doubt...

i am building a signup-login form, with user, admin, and a manager

I am using Werkzeug to hash password.

2 tables in use are:

1) Employees (consisting of admins and employees)

2) Users

now let's say, an admin logs in.

Admin changes manager's role to an user's.

I then restart the server (in order to migrate manager from Employee table to user's table)

now when I am logging in with the managers credentials, the hashed password isn't been read, and i can't log in. Whats with this error?


if i am migrating employee's password to user's password (even if as a script), shouldn't it read the hashed password using check_password_hash?


what else can i do?

/r/flask
https://redd.it/1e9aa14
What is the safest way to secure env variables?

Is it OK if I create a separate service with independent database and store everything there and call it via api?

Or is there any other approach that has more potential for keeping it safe?

Asking because my vps is constantly getting attacked with ssh bruteforce bots. I have banned more than 1800 IP addresses so far but they are not fudging.

/r/django
https://redd.it/1e99rea
Defining a Custom Unknown Type in Python

I wrote up a short blog post based on an interesting workaround mentioned in this StackOverflow post for simulating an unknown type in Python.

If you have a better solution, feel free to share it!

/r/Python
https://redd.it/1e942fx
What are people's experience with Celery?

I thought I had a good use case for Celery but I found myself struggling and getting nowhere with it after several hours even to get a basic setup working. I eventually went back to using Cron jobs. Has anyone else got a basic example of a simple working project with Django using Celery? I had a devil of a time getting even a very simple example to work with it apparently not being able to find my celery.py file or complain about circular imports. I say apparently because it doesn't show errors to that effect but it appears not to execute that file. I am just after a basic minimal getting started example. I spent hours on this and got nowhere.

Are people still using Celery for new projects or something else?

/r/djangolearning
https://redd.it/1e8db7t
Mypy 1.11 Released

https://mypy-lang.blogspot.com/2024/07/mypy-111-released.html

Features include:

Support Python 3.12 Syntax for Generics (PEP 695)
Support for functools.partial
Stricter Checks for Untyped Overrides
Type Inference Improvements
Improvements to Detection of Overlapping Overloads
Better Support for Type Hints in Expressions
Mypyc Improvements
etc.

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