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
No matter what i do, database record will not update while testing.

Hi, I'm trying to develop a simple crud app where user can save their contacts. Using django and htmx.

Naturally there must be a view to edit individual contacts. So the view works fine. Upon click, a htmx request is sent, a modal shows that will be populated with a form, and the form itself is prepopulated with that specific record data.

Upon submitting, a htmx post request is sent, record is updated, i trigger an event (using HX-Trigger) to clean up the form, close the modal, and refresh the table.

Everything is OK so far.

The problem is when i try to test this view. Using pytest (for fixtures) and pytest-django (for database access). The status code will return 200, but the record itself will NOT update (i check the record before and after the request).

Here is the code:

View (Contact is my model):

@loginrequired
def contact
edit(request: HttpRequest, pk: int) -> HttpResponse:
    context = {}
    try:
        item = Contact.objects.get(pk=pk)
        if item.user != request.user:
            raise Contact.DoesNotExist("Such

/r/django
https://redd.it/1kjimw2
are non-SPA websites outdated?

I am learning django, fairly new, developing a big project right now slowly to put on my resume and as a hobby in general, i have notice that to make the user experience smoother and to beat the dull atmosphere i'd need to incorporate alot of JS that i have never used, i've actually never touched js code which makes me intimidated by web development now, my question i guess is are non-SPA websites still fine where you wouldnt have all these cool transitions in the website and instead have a bunch of pages linking to each other and whatnot, because i dont want to rely on chatgpt to give me js code that i cant even read and put on a passion project.

/r/django
https://redd.it/1kj5x0i
fastAPI & flask

Has anyone ever built an end-to-end web app using fastAPI(to build the APIs) and flask(for the templates, ie frontend)?

I was wondering how this even looks like in practice. Say you're using the create app factory-blueprint method for your flask side. You need to register routes and all that stuff. How will you tie this to your API that uses fastAPI?
Putting a reverse proxy like caddy further complicates things(I think). Do you run the fastAPI app and the flask app separately??

I understand that you can technically build everything using fastAPI as it supports templating using Jinja. But I'm just wondering if fastAPI and flask is even possible.

/r/flask
https://redd.it/1kjmdlp
Bootstrap 5 + Jinja + Forms

Can somebody recommend any decent library / macro set that will render Django form in jinja templates ? I don’t want to reinvent the wheel…

/r/django
https://redd.it/1kjbr9r
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/1kjnxrz
Announcing Traeger 0.2.0, now with Rust bindings (and Python and Go).

Traeger is a portable Actor System written in C++ 17 with bindings for Python, Go and now Rust.

https://github.com/tigrux/traeger

The notable feature since version 0.1.0 is that it now provides bindings for Rust.

The Quickstart has been updated to show examples in the supported languages.

https://github.com/tigrux/traeger?tab=readme-ov-file#quick-start

For version 0.3.0 the plan is to provide support for loadable modules i.e. to instantiate actors from shared objects.

/r/Python
https://redd.it/1kjlcqm
cybersecurity project using python

heyo! I tried to make a keylogger using python, it works well, any suggestion to make it better.

source: https://github.com/Debang5hu/Keylogger

btw im planning to just focus on windows and rewrite it using c++

kudos

/r/Python
https://redd.it/1kjvs81
🚀 I built a lightweight task management system for Django projects

Hey r/django community!

I wanted to share a library I've been working on called **django-async-manager** \- a lightweight, database-backed task management system for Django projects.

# Why I built this

While working on Django projects, I often needed to run tasks asynchronously but found that Celery was sometimes overkill for simpler projects. I wanted something that:

* Didn't require additional infrastructure like Redis or RabbitMQ
* Was easy to set up and integrate with existing Django projects
* Provided essential task management features without complexity
* Used the database as a reliable task queue

# Key Features

* **Background Tasks**: Run Django functions asynchronously
* **Task Scheduling**: Schedule tasks using cron-like syntax
* **Task Dependencies**: Define dependencies between tasks
* **Priority Queues**: Process important tasks first
* **Automatic Retries**: Configure retries with exponential backoff
* **Multiple Workers**: Run workers using threads or processes
* **Task Timeouts**: Set timeouts for long-running tasks
* **Monitoring**: Track task status, execution time, and errors

# Super Easy to Use

Setting up is straightforward:

# 1. Install
pip install django-async-manager

# 2. Add to INSTALLED_APPS
# 3. Run migrations
python manage.py migrate django_async_manager

# 4. Define a

/r/django
https://redd.it/1kjx8o5
I Shared 290+ Python Data Science Videos on YouTube (Tutorials, Projects and Full-Courses)

Hello, I am sharing free Python Data Science Tutorials for over 2 years on YouTube and I wanted to share my playlists. I believe they are great for learning the field, I am sharing them below. Thanks for reading!


Data Science Full Courses & Projects: https://youtube.com/playlist?list=PLTsu3dft3CWiow7L7WrCd27ohlra\_5PGH&si=UTJdXl12Y559xJWj



End-to-End Data Science Projects: https://youtube.com/playlist?list=PLTsu3dft3CWg69zbIVUQtFSRx\_UV80OOg&si=xIU-ja-l-1ys9BmU



AI Tutorials (LangChain, LLMs & OpenAI Api): https://youtube.com/playlist?list=PLTsu3dft3CWhAAPowINZa5cMZ5elpfrxW&si=GyQj2QdJ6dfWjijQ



Machine Learning Tutorials: https://youtube.com/playlist?list=PLTsu3dft3CWhSJh3x5T6jqPWTTg2i6jp1&si=6EqpB3yhCdwVWo2l



Deep Learning Tutorials: https://youtube.com/playlist?list=PLTsu3dft3CWghrjn4PmFZlxVBileBpMjj&si=H6grlZjgBFTpkM36



Natural Language Processing Tutorials: https://youtube.com/playlist?list=PLTsu3dft3CWjYPJi5RCCVAF6DxE28LoKD&si=BDEZb2Bfox27QxE4



Time Series Analysis Tutorials: https://youtube.com/playlist?list=PLTsu3dft3CWibrBga4nKVEl5NELXnZ402&si=sLvdV59dP-j1QFW2



Streamlit Based Web App Development Tutorials: https://youtube.com/playlist?list=PLTsu3dft3CWhBViLMhL0Aqb75rkSz\_CL-&si=G10eO6-uh2TjjBiW



Data Cleaning Tutorials: https://youtube.com/playlist?list=PLTsu3dft3CWhOUPyXdLw8DGy\_1l2oK1yy&si=WoKkxjbfRDKJXsQ1



Data Analysis Tutorials: https://youtube.com/playlist?list=PLTsu3dft3CWhwPJcaAc-k6a8vAqBx2\_0t&si=gCRR8sW7-f7fquc9



/r/Python
https://redd.it/1kk1hx5
Streamlit Alternatives with better State Management

Hi everyone,

I’m a developer at a small company (max 20 users), focusing on internal projects. I’ve built full applications using Python with FastAPI for the backend and React for the frontend. I also have experience with state management tools like Redux (Thunks, Sagas), Zustand, and Tanstack Query.

While FastAPI + React is powerful, it comes with significant overhead. You have to manage endpoints, handle server and client state separately in two different languages, and ensure schema alignment. This becomes cumbersome and slow.

Streamlit, on the other hand, is great for rapid prototyping. Everything is in Python, which is great for our analytics-heavy workflows. The challenge arises when the app gets more complex, mainly due to Streamlit's core principle of full-page re-renders on user input. It impacts speed, interactivity, and the ghost UI elements that make apps look hacky and unprofessional—poor UX overall. The newer versions with fragments help with rerenders, but only to a degree. Workarounds to avoid rerenders often lead to messy, hard-to-maintain code.

I’ve come across Reflex, which seems more state-centric than Streamlit. However, its user base is smaller, and I’m curious if there’s a reason for that. Does anyone have experience with Reflex and can share their insights? Or

/r/Python
https://redd.it/1kk3xtn
SmolML: Machine Learning from scratch, explained!

# What my project does

Hello everyone! Some months ago I implemented a whole machine learning library from scratch in Python for educational purposes, just looking at the concepts and math behind. No external libraries used.

I've recently added comprehensive guides explaining every concept from the ground up – from automatic differentiation to backpropagation, n-dimensional arrays and tree-based algorithms. This isn't meant to replace production libraries (it's purposely slow since it's pure Python!), but rather to serve as a learning resource for anyone wanting to understand how ML actually works beneath all the abstractions.

The code is fully open source and available here: https://github.com/rodmarkun/SmolML

# Target audience

Students, developers, educators, or basically anyone who wants to learn how ML works on the inside. If you're learning ML or just curious about the inner workings of libraries like Scikit-learn or PyTorch, I'd love to hear your thoughts or feedback!

# Comparison

While other similar projects use already established libraries like NumPy or Scikit-learn, everything in SmolML is made from scratch. Guides are also provided in order to understand every concept included.

/r/Python
https://redd.it/1kjznn4
How to make a flask app access an api via vpn?

Hi guys. I'm new to flask so this question may be a little strange.

I have a flask app that access a rest API that works only in Italy, that works fine in local.

But when I deploy my app on PythonAnywhere or Render, it won't work because it is deployed in europe (I think, like in Frankfurt) and it can't access the api (An error occurred: 403 Client Error: Forbidden for url: https://***.******.com/rest/v1/auth/login)

Is there a way to access to that api and bypass the geoblock like via vpn? And how to implement that in flask?

Any way to solve this situation would be appreciated. Thank You!

/r/flask
https://redd.it/1kk2ts1
Djoser | password reset nightmare

Hi community! I’m using Djoser + Django REST Framework for authentication and I’m getting a little frustrated about the password‑reset flow (JUST A LITTLE 🥲).
My password‑reset emails generates links like: (http://localhost:8000/auth/users/reset_password_confirm/uid/token/)

The problem is that this endpoint expects a POST with the user’s new password, but clicking the link issues a GET, so the request fails immediately.

Most of the solutions I’ve found feel hacky, because they require either:
\- Overriding the Djoser view to handle a GET (redirecting to my frontend) and then handling a POST to the same URL to set the new password
\- Modifying Djoser’s email templates (which just feels bad to me)

Does anyone know a cleaner way to work around this? Any alternative patterns, suggestions, or insights would be hugely appreciated!

/r/djangolearning
https://redd.it/1kfdibf
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/1kkezzz
First Django project! Need suggestions with "front-end"

Hi all! I'm working on my first Django project, using Django (obvs) and DRF. I have the basics ready to deploy the project and have it ready as a portfolio piece. For a portfolio, I'm wondering how I can display the web app. Right now I'm using DRF's browsable API, I'm wondering if it's best to use Django templates to add some user friendliness to the project, or would it be worth learning React to 1 expand my skill set. 2. Have a better-looking project, or is there a better alternative anyone could suggest? I appreciate any help, guys!

/r/django
https://redd.it/1kka0sa
[D] What Yann LeCun means here?

/r/MachineLearning
https://redd.it/1kk19ob
Zeet

I created a Django app that I’m trying to deploy using Zeet. I’m having trouble on Step First. After I go to Zeet.co and sign in using my GitHub account, which authenticates successfully, I am redirected to zeet.co/contact. After that, all attempts to get to any other Zeet page, such as the dashboard, gets redirected to the Contact page. I’m stuck.

/r/django
https://redd.it/1kk3eba
Hands on machine learning with sickit learn.

i had a question related to the book hands on machine learning with sickit learn the question is that for me the chapter 2 is quite hard as it is an end to end ml project so i wanted to know if the ucoming chapters are easy like i am an intermediate or they will be hard as well and if should i continue.

/r/Python
https://redd.it/1kkktef
I’m new to web development. Should I learn Flask before Django?

What’s the easiest tutorial for building my first Flask website?

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