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
I'm trying to run this app outside of the localhost and I kepp gettinting this error

Access to fetch at 'http://rnkfa-2804-14c-b521-813c-f99d-84fb-1d69-bffd.a.free.pinggy.link/books' from origin 'http://rnjez-2804-14c-b521-813c-f99d-84fb-1d69-bffd.a.free.pinggy.link' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

script.js:65



GET [http://rnkfa-2804-14c-b521-813c-f99d-84fb-1d69-bffd.a.free.pinggy.link/books](http://rnkfa-2804-14c-b521-813c-f99d-84fb-1d69-bffd.a.free.pinggy.link/books) net::ERR\_FAILED 200 (OK)

loadAndDisplayBooks @ script.js:65

(anônimo) @ script.js:231


app.py:

# Importa as classes e funções necessárias das bibliotecas Flask, Flask-CORS, Flask-SQLAlchemy e Flask-Migrate.
from flask import Flask, request, jsonify
from flask_cors import CORS
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
import os # Módulo para interagir com o sistema operacional, usado aqui para acessar variáveis de ambiente.

# Cria uma instância da aplicação Flask.
# __name__ é uma variável especial em Python que representa o nome do módulo atual.
app = Flask(__name__)
# Habilita o CORS (Cross-Origin Resource Sharing) para a aplicação.
# Isso permite que o frontend (rodando em um domínio/porta diferente) faça requisições para este backend.
CORS(app,
origins
="http://rnjez-2804-14c-b521-813c-f99d-84fb-1d69-bffd.a.free.pinggy.link")


# Configuração do Banco de Dados


/r/flask
https://redd.it/1kzpix5
Do you use django's caching framework?

Just got to know about this one: https://docs.djangoproject.com/en/5.2/topics/cache/ (good docs!)

It says, for small to medium sites it isn't as important. Do you use it, e.g. with redis to cache your pages?

Oh and I don't know if it is just me, but whenever I deploy changes of my templates, I've to restart the gunicorn proccess of django in order to "update" the site on live.

/r/django
https://redd.it/1kzm97i
Django’s URL philosophy seems to contradict Domain Driven Design

Hey everyone, I’ve been using Django for many years now, but just recently started learning about DDD. There’s one part in Django’s docs that I’m trying to relate (https://docs.djangoproject.com/en/5.2/misc/design-philosophies/#id8):

> URLs in a Django app should not be coupled to the underlying Python code. Tying URLs to Python function names is a Bad And Ugly Thing.

At the heart of DDD is a ubiquitous language, which so far to my understanding, I think, means to prefer using the same language across the business logic, to the URL, to the Python function names, and even perhaps to the form class name, and even template file name. Ideally to prefer that way, at least. Needless to say, I know that that’s not a rule cast in stone, there’ll always be exceptions and considerations.

BUT the way Django’s docs portrays it seems to suggest like that’s not the way to think about it AT ALL.

What do you think?

/r/django
https://redd.it/1kzzxg9
Deploying on LAN

Hi, it’s my first time deploying a web app and I’d like to know if what I’m gonna do is right.
I have a Django application that I need to deploy on a windows machine and make that useable in the LAN.
the step that I did were:
- set DEBUG = False, ALLOWEDHOSTS=[*] and CSRFTRUSTEDORIGINS=[‘http://<PC IP IN LAN>’]
- installled waiterss and setup
serve.py script using address 0.0.0.0 and port 8000
-setup Nginx for reverse proxy this way :
Location / {
Proxy
pass http://localhost:8000
}
this setup works and I can use application on other device in the same LAN, but I’d like to know if I missed something or I did something unsafe.

Thanks for reading and for the help.

/r/djangolearning
https://redd.it/1kxdbdn
Views on recent acceptance of LLM written paper at ACL main D

Hi folks, just came across this blog
https://www.intology.ai/blog/zochi-acl

It started with ICLR workshop and now ACL main, was just wondering where are we heading. Is this all the effect of noise review process, or indeed the works are worth publishing

PS: Not a NLP guy, so couldn't really comment on the novelty/technical correctness of the work

Edit: Just found a GitHub repo, corresponding to the agent
https://github.com/IntologyAI/Zochi?tab=readme-ov-file

/r/MachineLearning
https://redd.it/1l074er
Sunday Daily Thread: What's everyone working on this week?

# Weekly Thread: What's Everyone Working On This Week? 🛠️

Hello /r/Python! It's time to share what you've been working on! Whether it's a work-in-progress, a completed masterpiece, or just a rough idea, let us know what you're up to!

## How it Works:

1. Show & Tell: Share your current projects, completed works, or future ideas.
2. Discuss: Get feedback, find collaborators, or just chat about your project.
3. Inspire: Your project might inspire someone else, just as you might get inspired here.

## Guidelines:

Feel free to include as many details as you'd like. Code snippets, screenshots, and links are all welcome.
Whether it's your job, your hobby, or your passion project, all Python-related work is welcome here.

## Example Shares:

1. Machine Learning Model: Working on a ML model to predict stock prices. Just cracked a 90% accuracy rate!
2. Web Scraping: Built a script to scrape and analyze news articles. It's helped me understand media bias better.
3. Automation: Automated my home lighting with Python and Raspberry Pi. My life has never been easier!

Let's build and grow together! Share your journey and learn from others. Happy coding! 🌟

/r/Python
https://redd.it/1l0bcrd
Tired of tracing code by hand?

I used to grab a pencil and paper every time I had to follow variable changes or loops.

So I built DrawCode – a web-based debugger that animates your code, step by step.
It's like seeing your code come to life, perfect for beginners or visual learners.

Would appreciate any feedback!

/r/Python
https://redd.it/1kzq9vi
Hosting django web app on Hostinger

Can anyone help me how to host django web app in hostinger?
Client purchased Hostinger KVM 2 plan.

/r/django
https://redd.it/1l062a3
Python Object Indexer

I built a package for analytical work in Python that indexes all object attributes and allows lookups / filtering by attribute. It's admittedly a RAM hog, but It's performant at O(1) insert, removal, and lookup. It turned out to be fairly effective and surprisingly simple to use, but missing some nice features and optimizations. (Reflect attribute updates back to core to reindex, search query functionality expansion, memory optimizations, the list goes on and on)

It started out as a minimalist module at work to solve a few problems in one swoop, but I liked the idea so much I started a much more robust version in my personal time. I'd like to build it further and be able to compete with some of the big names out there like pandas and spark, but feels like a waste when they are so established

Would anyone be interested in this package out in the wild? I'm debating publishing it and doing what I can to reduce the memory footprint (possibly move the core to C or Rust), but feel it may be a waste of time and nothing more than a resume builder.

/r/Python
https://redd.it/1l0dum0
flask-security - Does anyone tried to embed a "change email" or "change password" form only in more general template ?


Rather than having a specific page to permit users to change their email (which is the default behaviour of flask-security), I would like to embed the html form in a more versatile template (user details where user can adjust any of its data).

I did this and it kinda work but... When submiting the email change request, the app systematicaly redirects to the default "change email" flask-security page. I should add that the confirmation email has already been sent at that moment.

I can't block the loading of the default template or force the redirection after submiting the embeded form.

Any clue ?

/r/flask
https://redd.it/1kz69ck
audio file to grayscale image

Hi, I'm trying to replicate this blender visualization. I dont understand how to convert an audio file into the image text that the op is using. It shouldnt be a spectrogram as blender is the program doing the conversion. so im not sure what the axes are encoding.

https://x.com/chiu\_hans/status/1500402614399569920

any help or steps would be much appreciated


/r/Python
https://redd.it/1l0fses
relation "{my app name}{my model name}" does not exist

Hi,

I'm working on a multilingual site, I've created models for languages courses, and they used to work fine, but as I'm working I found out that I need to add a couple more models to it so that I can have an api that looks like this:

{
"id": 1,
"langProgram": "English Program",
"courses": [
{
"id": 1,
"translations": [
{
"language
code": "en",
"title": "English for School Students",
"description": {


/r/django
https://redd.it/1l0sc4n
Have Erasmus+ scholarship and I'm looking for a 2-month internship in any EU country

Hello everyone 👋
I’m a final-year SWE student graduating in early July.

I’ve secured an Erasmus+ scholarship and I'm currently looking for a two-month internship opportunity where I can grow both technically and professionally.

I'm open to any tech role since I’m just starting my career, I’m eager to gain experience in anything I work on. That said, I’d love something backend-related with Django, since I really enjoy working with it. My graduation project is actually a hospital management system built with DRF and Next.js.

Right now, I’m doing a remote internship with a U.S. based company, but I want to make the most of the Erasmus+ program to expand my skills and network.

I just need a company to send me an acceptance letter and erasmus and I will take care of everything else.

I’d really appreciate any support or referrals 🙏

/r/django
https://redd.it/1l0n67m
Every time I touch settings.py, I age 3 years.

Why does configuring Django feel like diffusing a bomb with a blindfold on… while it’s also on fire… and your cat is stepping on the keyboard? Meanwhile, Node devs just vibe with dotenv. 😂 Let's unite, scream into the void, and pretend we totally understand ALLOWED_HOSTS.

/r/django
https://redd.it/1l0sxr7
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/1l13tl7
D Self-Promotion Thread

Please post your personal projects, startups, product placements, collaboration needs, blogs etc.

Please mention the payment and pricing requirements for products and services.

Please do not post link shorteners, link aggregator websites , or auto-subscribe links.

\--

Any abuse of trust will lead to bans.

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.

\--

Meta: This is an experiment. If the community doesnt like this, we will cancel it. This is to encourage those in the community to promote their work by not spamming the main threads.

/r/MachineLearning
https://redd.it/1l16j5k
ayu - a pytest plugin to run your tests interactively

# What My Project Does

ayu is a pytest plugin and tui in one.
It sends utilizes a websocket server to send test events from the pytest hooks directly to the application interface to visualize the test tree/ test outcomes/ coverage and plugins.

It requires your project to be uv-managed and can be run as a standalone tool,
without the need to be installed as a dev dependency.
e.g. with:
uvx ayu


Under the hood ayu is invoking pytest commands and installing itself on the fly, e.g. uv run --with ayu pytest --co is executed to run the test collection.

You can check the source code on github: https://github.com/Zaloog/ayu

# Target Audience
Devs who want a more interactive pytest experience.

# Comparison

Other plugins which offer a tui interface e.g. pytest-tui https://github.com/jeffwright13/pytest-tui exist.
Those are only showing a interface for the results of the test runs though
and do not support for example
- searching/marking specific tests and run only marked tests
- exploring code coverage and other plugins




/r/Python
https://redd.it/1l0wgq3
Can you suggest good blog or post explainng how asyncio and gRPC works in python specially with Django

I specially do not get how loops are created and assigned to function and if you create new custom loop how to solve conflict

/r/djangolearning
https://redd.it/1l1erss