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
stick or move to another

So i made an inventory management system in Django for my internship project.

i chose Django for several reasons:
- i wanted to learn python and discover how to do weB apps with it
- i wanted to be unique because all of my colleagues used PHP (Laravel)
- Django has pretty much everything compared to Flask
- ...

Django is the first backend web framework i ever tried.

About the experience..., it was not that good i don't why.
Is it bc the result code IT WAS LITERALLY A MESS

i could not fix bugs or add features without breaking something
and then rollback to the previous version.

and sometimes i wanted to something simple but Django make it hard
like custom forms and how to integrate Django with CSS frameworks make it
an absolute MESS.

what i am missing in my knowledge to have a great experience with Django?

do i miss something in Django or in web/dev itself?

did you have some issues too with Django at your early days learning it?

should i move to something else like Laravel or Spring (ik some Java and PHP)
or just stick with Django?

bc i feel like it is not for me.

project repo

i hope i explained the problem.
thank you in advance.

/r/django
https://redd.it/1g6q4h5
Aid with using anaconda to load fashionmnist

Hello could someone please step out how from the anaconda.navigator to load fashion
mnist (which is on a laptop that’s never run it and may be missing things needed)

/r/Python
https://redd.it/1g6wjqj
Best resources to learn

Having always use node js for my backends, I’m trying to widen my skills. What are the go to resources to learn Django?

/r/djangolearning
https://redd.it/1g6ull9
Django SQL Lite DB Built-in Size !?

I want to create a django app but for now i use a script on my PC the fetch some data and all the final results are stored into a json that can reach size of 600 to 700 MBs.... Can the DB store this size ? I have a hosting provider where to put the app on and unfortunate, my current plan doesn't have access to bigger DBs, only some that can store up to 350 MBs...

/r/django
https://redd.it/1g7022w
filefrag - library and executable to explore file fragmentation

Spent last night making this, added some turd polish today and added it to pypi.

## 🀷 why/what?

I wanted to get file fragmentation info so I can punch holes in files, aligned with memory pages. But I really didn't want to parse filefrag's outputs, so I wrote a python version with a friendly API and a command line that can produce json.

It only works on Linux as it depends on the FIE interface, but pull requests welcome etc.

## βš’οΈ how?

See the video for a demo including installing from source, but you can install with pip:

pip install filefrag

Then you can run pyfilefrag, see --help for details. It has --verbose, and --json outputs for your parsing pleasure.

To use the library, just call filefrag.FileMap('/path/whatever') to build a map of the extents in the file using ioctl's interface. Then you can poke about in the guts of a file:

⛓️‍πŸ’₯ inspect fragmentation
πŸ” find out where data is on your physical drive
🟰 compare extents between paths
πŸ“” use them as dict keys
πŸ•³οΈ check files for holes, like before and after hole punching
βœ…verify your XFS deduplication strategy, write your own stats tool
πŸ’© dump file layouts to json (`print(f"{filemap:j}"`)
⚠️ break your disk

/r/Python
https://redd.it/1g70lqb
How to write the Terms and privacy section of the website ?

i got to that point where you must write the terms and privacy, and i was thinking if there is a custom terms or privacy to include or rules to follow when writing them, any suggestions ?

/r/djangolearning
https://redd.it/1g765b5
FriendlyDateParser, just another Python module for date parsing!

Hello!

I've just released **FriendlyDateParser**, just another Python module for date parsing.


## What My Project Does

It can parse complex date expressions like:

* `2 days before the last day of next month`
* `1h15m after next Sunday at midnight CEST`
* `the second Monday of 2012`

The goal is to make working with date references straightforward, even when the expressions are complex.


## Target Audience

At this point, the module is still young and bugs should be expected. There may still be some edge cases which are not handled correctly.


## Comparison

Well, actually the reason for writing this module is that I had been using [**dateparser**](https://dateparser.readthedocs.io/) (*the* mature module with a similar purpose) for a while, but I found it was not able to handle all the cases I needed. So, I created **FriendlyDateParser** to address those gaps.

On the other hand, `dateparser` is multilingual while `friendlydateparser` only support English expressions (and I don't plan to extend the module in that way).

## Links

Check out the documentation and repo [here](https://github.com/salva/py-friendlydateparser)!

The module is also available from [PyPI](https://pypi.org/project/friendlydateparser/)



I'd love to hear your feedback and see how it works for you!

/r/Python
https://redd.it/1g6nwca
Creating simple inventory management app

Hi all, I'm trying to learn about Flask and decided to create a simple inventory management app which allows me to add, remove and edit entries in sqlite db using frontend. I was able to make the python app work but I'm stuck on the frontend part. I have the html file in "templates" folder and the the js script in the "static" folder, but when I try to run it, I end up with this error: "Failed to load resource: the server responded with a status of 404 (NOT FOUND)". Can someone help me out on what I'm missing?
Here's my repo: https://github.com/iraklikeshelava/inventory-management

/r/flask
https://redd.it/1g6fcyb
Real-time YouTube Comment Sentiment Analysis with Kafka, Spark, Docker, and Streamlit

Hey r/Python! πŸ‘‹

# What My Project Does:

This project performs real-time sentiment analysis on YouTube comments using a stack of Kafka, Spark, Docker, and Streamlit. It classifies comments into positive, neutral, or negative sentiments and displays the results in a web interface for easy visualization and interpretation. The aim is to provide insights on how users are reacting to YouTube videos in real-time, which can be especially useful for content creators, marketers, or analysts who want to track audience reception.

# Target Audience:

This project is primarily a learning-focused, proof-of-concept to demonstrate the power of real-time big data analytics with modern tools. While it could potentially be expanded into a production-ready system, it’s currently a toy project meant for educational purposes and exploring various technologies. Developers looking to explore Kafka, Spark, and Streamlit in a Dockerized environment will find this project helpful.

# Comparison:

What sets this project apart from existing alternatives is its real-time processing capability combined with the use of big data tools. Most sentiment analysis projects process data in batch mode or on a smaller scale, while this project uses Kafka for real-time streaming and Spark for distributed processing. It’s also containerized with Docker, which makes it easy to deploy and scale.

/r/Python
https://redd.it/1g7cs5l
Symlink in static dir to serve files

I understand that only images within the static dir can be displayed directly for security purposes.
Does creating a symlink within static, pointing to another folder, pose a security risk? How would someone go about exploiting this to access other data on the server?

/r/flask
https://redd.it/1g6n3ym
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/1g7m7nw
Feel like an ostracized freak for using Django as a monolithic websocket backend

Never did web-development before this and wanted to create the simplest possible websocket web app in python with a database.
I have Django serving my react.js frontend and handling the async websockets through channels. I don't use redis, celery, or microservices.
My backend code is async, so using one server process for multiple users works perfectly without scaling issues. I don't need a distributed task queue system since my async code is basically just waiting for IO. When I have something CPU intensive like gunzipping I just use a ProcessPoolExecutor to not block the event loop.

There's basically no documentation on how to set up the app the way I did and it's basically just been me hacking and experimenting with what works. I feel like I've been using django the wrong way since day one since every guide is either simple synchronous forum website, or straight to redis/celery/rabbitmq/kubernetes/gunicorn. There's no common ground.

/r/django
https://redd.it/1g7e8yf
Firebase for authentication ?

Hey everyone! What do you think about using Firebase authentication in Django instead of Django Alluth?
Which one has been the better experience for you? ( or any other other auth provider like Supbase) , Thanks

/r/django
https://redd.it/1g7qfy2
Getting started with DRF for my VueJS frontend

Hello, so I posted something similar to this issue a week ago or less. But I'm trying to connect my Django project to my VueJS frontend pages that I created using DRF.


To my understanding I have to create API with DRF, so I was following the DRF docs tutorial and followed everything it said for coding the views, serializers, etc.... But then I ran `python manage.py runserver` and this caused all kinds of errors.

So I decided it was for the best to clone my project from my remote repo on Github and start all over with DRF. Now that I'm back to square one, my question is, what approach should I do to get started with DRF to create API end points for my frontend and backend? I want to try again with the DRF docs, but I don't want to fuck up my project again with an endless cycle of errors.


I'm beginning to think that I should just create a new app within my project, maybe that's what threw the errors I was getting before. What do you guys think? Here is the link to my Github repo, the project name is MyProject https://github.com/remoteconn-7891/MyProject.

/r/django
https://redd.it/1g7prk8
Unexpected Behavior with Flasgger

Hi all,

While I am versed in Python/Flask ...

I have a bit of an issue with my swagger docs - first timer here. I am open both to solutions using my current libraries and completely novel solutions where I tear it all down.

My current `YAML` implementation renders just fine on https://editor.swagger.io/ and passes other online `YAML` validation tools, so this is definitely a "well it works on X machine" sort of thing - I get it. Please help me my fellow Pythonistas!

While the most important file, my YAML is the longest so I pasted it at the end. Scroll if you want to skip. Not sure if it is this file or a problem with the flasgger lib.

relevant libraries:
flasgger 0.9.7.1
Flask 3.0.3
Flask-Cors 5.0.0
Flask-RESTful 0.3.10

# root/api/config.py

#!/opt/homebrew/bin python3.12

import os

# api config base class


/r/flask
https://redd.it/1g6079j
Deployed flask app with SQLite database doesn't have data persistance

I developed a flask application with a SQLite database and deployed it on Render however I realised that the being stored or updated to the application after deployment gets lost after some time. Upon further research online, I read that I should switch to a PostgreSQL database. However, I have the following questions:

1. Why is the deployed application failing to save data yet during development it worked fine?
2. If both SQLite and PostgreSQL databases are relational databases, how come PostgreSQL can maintain data persistence after deployment and SQLite databases can't?
3. What alternative deployment services can I use that support PostgreSQL databases and data persistence after deployment?

/r/flask
https://redd.it/1g5nfs7
Are all the scientific python subreddits dead?

I have checked r/scipy and it doesn't look like it has had any posts for years. Where do people go to discuss scientific applications of python now? I have implemented a Biot Savart equation simulation I am looking for some feedback on.

/r/Python
https://redd.it/1g7t726
Problem uploading files larger than 125kB

Hi guys!

There's a problem with a Django website, that I'm working on. The website has been setup a year ago at a hosting provider that uses cPanel and it has worked perfectly, but a few days ago something broke and now no one is able to upload any file larger than 125kB or groups of files, whose size is bigger than 125kB through the website. When someone tries to upload files larger than that, the page just simply loads till infinity without actually making any progress or creating the file on the disc. It's also important to not that when I tried to upload a file larger than 125kB in the Django admin panel and I left some fields empty, which can't be null, the infinite loading still happened, so it seems, that the problem is caused before the form validation takes place. These problems also aren't present when I try to upload the files on the local debug version.

We have one more Django based website at this provider and this happened to that as well. I even tried setting up a fresh Django project to test whether something broke, but the same issue arose. Meanwhile it's perfectly possible to

/r/django
https://redd.it/1g7utua
Mutmut 3 released

I've just released version 3 of mutmut, the industry standard mutation tester for Python. It's an almost complete rewrite to using mutation schemata, which (when coupled with some other changes) massively improve performance.

There is also a new terminal based UI for working with mutants that makes doing MT much faster and more fun.

Docs: https://mutmut.readthedocs.io/

Code: https://github.com/boxed/mutmut

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