Python Daily – Telegram
Python Daily
2.56K subscribers
1.49K photos
53 videos
2 files
39K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Should I extend Django's roles and permissions, or should I create my own roles and permissions layer?

Hello everybody, I want to develop a project management web app as a learning experience, and I have thought about the functionality of the roles and permissions for the users of the web app. Should I extend the Django system and not get too complicated, or should I keep the project roles separate? And about the users? I have also thought about adding specific things like: "You can mark a task as completed", "You can see all the team's tasks" etc. Thank you in advance for taking the time to read and leave your recommendations.

/r/django
https://redd.it/1g69h7g
Best way to upload file in Django

What's difference using Django UploadFileForm described at https://docs.djangoproject.com/en/5.1/topics/http/file-uploads/

from FileUploadView APIView?

Why should it be serialized? And how is the file is serialized?

Why doesn't it just dump the binary on disk?

It looks like they're making simple thing very hard.

/r/django
https://redd.it/1g6c4a7
Django + Celery Tutorial

Hey, all!

I've made a text + video version of Celery tutorial.

Video: https://www.youtube.com/watch?v=RY74ug36KUc

Text: https://appliku.com/celery

This tutorial aims at beginners who struggle with understand what Celery is and how to use it and never set it up before.

I tried to do my best explaining use the concept of it, use cases + step by step instructions on setting Celery app.

The last bit is a real world example of a generating reports using Celery tasks.

Let me know what you think and I hope it helps at least few people to start using this powerful library!

/r/django
https://redd.it/1g6ela0
Chat System/Room

Trying to build a chat system where a user can build a chat room and invite some users to chat amongst them.

I have never built a chat system before.Also,this is a backend api project where I'm building api for the frontend.Where and how should I start.

I have built some api and common apps with django and django rest framework.I have the general idea.

/r/django
https://redd.it/1g6fk0a
Feature Friday: Model Choices!

Time for another Django Feature Friday! 🚀

Django 5.0 introduced more options for declaring field choices. Now you can use Mapping, a callable, and strings for single-character choices, in addition to the traditional tuples and enumeration.

Previously, Field choices were limited to list of 2-tuples, or an Enumeration types subclass. Now, you can use:

* Strings (for single-character choices) without .choices
* Mapping instead of list of 2-tuples (with hierarchies)
* A callable instead of iterable

Here's an example showcasing these new options:

from django.db import models

Medal = models.TextChoices("Medal", "GOLD SILVER BRONZE")

SPORT_CHOICES = { # Using a mapping instead of a list of 2-tuples.
"Martial Arts": {"judo": "Judo", "karate": "Karate"},
"Racket": {"badminton": "Badminton", "tennis": "Tennis"},
"unknown": "Unknown",
}


def get_scores():
return [(i, str(i)) for i in range(10)]


class Winner(models.Model):


/r/django
https://redd.it/1g6grym
PyTraceToIX - Debugging Jinja2 template, Flask web apps without breaking the design or code changes

Project on GitHub

## What My Project Does

PyTraceToIX is an expression tracer designed for debugging Jinja2 templates, Flask web apps, lambdas, list comprehensions, method chaining, and expressions in general.

Code editors often cannot set breakpoints within these kinds of expressions, which requires significant code modifications to debug effectively.
For Jinja2 templates, the debug extension can be used, but it typically dumps the entire context, making it difficult to isolate specific issues.

PyTraceToIX solves this by allowing developers to trace and write specific data directly to sys.stdout or a stream without altering the design or making any changes to the web application.

Additionally, PyTraceToIX can capture multiple inputs and their results, displaying them all in a single line, making it easier to view aggregated data and trace the flow of values.

PyTraceToIX offers a straightforward solution to these challenges, simplifying debugging while preserving the integrity of the original codebase.
It was designed to be simple, with easily identifiable functions that can be removed once the bug is found.

PyTraceToIX has 2 major functions:
- c capture the input of an expression input. ex: c(x)
- d display the result of an expression and all the captured inputs. ex: d(c(x) + c(y))

And 2 optional functions:
- init initializes display format, output stream and

/r/Python
https://redd.it/1g6fd28
I built an open-source AI-driven Code Review app for GitHub repos

What My Project Does

Hi Everyone,

I recently built an open-source GitHub app in Django/python that can post a detailed line-by-line code review on any new PR. I'd love help in testing it as I seek feedback on it.

Here is the app: https://gitpack.co/

Here is the source-code: https://github.com/gitpack-ai/gitpack-ai and an example PR review: https://github.com/gitpack-ai/gitpack-ai/pull/9

It's free for open-source repos, but I can enable this for private repos for a month or so, if you DM me. Appreciate your feedback! I hope you all can find value in it.

Target Audience

Anyone who is actively developing on GitHub

/r/Python
https://redd.it/1g6m2mb
I migrated from digital ocean to hetzner - (good experience)

I am building a streaming platform for my wife.

I tried to find the best option over all the cloud providers. At first I decided to use Digital Ocean because of their user friendly docs and UI. Also finding terraform docs was very easy. To be honest setting up the project was very easy so I can say I am satisfied with that.

However the outbound limit of 4TB, was a deal breaker for me. At the beginning I was thinking the limitting the video quality at 720P, however my wife wanted to have 1080P.

I started my search and find out that, hetzner was not only offering the cheap hardware but also the traffic limits were way better. To compare the numbers:

digital ocean: 24$
- 80gb ssd,
- 4gb ram
- 2Vcpu
- 4TB outbound

hetzner: 16€
- 160gb ssd
- 8gb ram
- 4Vcpu
- 20TB outbound.


So I decided to deploy my project on their servers. My concern was not finding good terraform docs for that, but tbh it was very easy and straight forward. In less then 3 hours I was able to run my

/r/django
https://redd.it/1g6kive
PyQt best option for commercial use?

I'm looking to possibly develop an app that will run on a Linux Desktop, specifically Ubuntu, and the latest OS X. The UI and performance are very important. Is PyQt my best option?

/r/Python
https://redd.it/1g6brra
Lost my sqlite database😱. After that I wrote a backup noscript that runs once a day

This is just a warning to all you guys, remember to backup your database cause shit happens. Now I rest easy cause I wrote a backup noscript that runs automatically once a day just to backup my db, I know its going to fill up my space very soon and raise my costs but I do think its worth it, by the way the project I lost the db for was still a new project so there was not a lot of records in there anyway so not all hope is lost

/r/django
https://redd.it/1g6l5dv
Saturday Daily Thread: Resource Request and Sharing! Daily Thread

# Weekly Thread: Resource Request and Sharing 📚

Stumbled upon a useful Python resource? Or are you looking for a guide on a specific topic? Welcome to the Resource Request and Sharing thread!

## How it Works:

1. Request: Can't find a resource on a particular topic? Ask here!
2. Share: Found something useful? Share it with the community.
3. Review: Give or get opinions on Python resources you've used.

## Guidelines:

Please include the type of resource (e.g., book, video, article) and the topic.
Always be respectful when reviewing someone else's shared resource.

## Example Shares:

1. Book: "Fluent Python" \- Great for understanding Pythonic idioms.
2. Video: Python Data Structures \- Excellent overview of Python's built-in data structures.
3. Article: Understanding Python Decorators \- A deep dive into decorators.

## Example Requests:

1. Looking for: Video tutorials on web scraping with Python.
2. Need: Book recommendations for Python machine learning.

Share the knowledge, enrich the community. Happy learning! 🌟

/r/Python
https://redd.it/1g6wbs0
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 noscript 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