pythondaily | Образование

Telegram-канал pythondaily - Python Daily

1102

Daily Python News Question, Tips and Tricks, Best Practices on Python Programming Language Find more reddit channels over at @r_channels

Подписаться на канал

Python Daily

Having hard time implementing search functionality in django

I'm a complete beginner in backend development and I'm currently working on a search functionality that includes multiple advanced filters. I'm using Django Filters for filtering, but since I'm new to this, I haven't found many tutorials on YouTube. Most of the content I came across relates to Q objects, which raises the question of which is better to use: Django Filters or Q objects?

Additionally, I'm gathering data from APIs for weather, air quality, and datasets related to the cost of living. I'm unsure how to store this data so that when users apply filters in their searches, the system can display relevant cities. The project is aimed at digital nomads looking for cities based on specific criteria.

I would greatly apprciate any guidance on these topics, and I apologize if my questions seem basic.

/r/django
https://redd.it/1g98l21

Читать полностью…

Python Daily

Personal portfolio

I made my personal portfolio using flask, I am serving a blog and resource sharing there. Just wanted to show it to the world, theres a link to a flask ecommerce template there under resources if someone wants to take a look! Also feedback is welcome
silverboi.me https://silverboi.me

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

Читать полностью…

Python Daily

Can I migrate my website from WordPress to a coded platform like Django

Five months ago, I posted a similar question on the WordPress subreddit, but it didn’t gain much traction, and the feedback was mostly negative, tbh.

My original post was along these lines:

"I'm currently trying to launch an e-commerce site using WordPress with a theme builder. I really believe this business idea can succeed in the near future (God willing). This might sound odd, but I feel uneasy about WordPress, even though I’ve never written a single line of code. To add to that, I’m not comfortable using Dokan (the marketplace plugin) either, as I want to create a highly customized multi-vendor marketplace."

Fast forward a few months, and I've returned to working on my website. I’m not as uncomfortable with WordPress anymore, and I’ve completed the entire site design—it looks great! But now, I’m aiming Big. I want to grow this into a fully-fledged platform with apps for buyers, sellers, and delivery. I’m considering finding a technical co-founder to build this vision from scratch. The challenge? My budget is tight (hence, WordPress initially).

Any advice on how to proceed or whether I should stick with WordPress? Should I really be looking for a co-founder at this stage?

/r/django
https://redd.it/1g8z6h0

Читать полностью…

Python Daily

Best framework for large scale web apps

Wondering what’s the community’s best web framework for building large scale and reliable web apps ? Especially django (with rest framework) VS flask VS fastapi

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

Читать полностью…

Python Daily

How long can you confidently build app using django from Flask experience?

recently learn web development using flask, started 3 months ago but not consistent, building a capstone project.
I notice that django jobs are in demand than flask.

Can you share the learning curve switching frameworks.?

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

Читать полностью…

Python Daily

temporals - A time, date and datetime periods support

Hi guys!


I'm excited (and mostly nervous) to share my first Python project that is aimed at the wider audience of Python users.


# What Does It Do


temporals aims to provide a minimalistic utility layer on top of the Python standard library's datetime package in regards to working with time, date and datetime periods.


The library offers three different flavours of periods:

`TimePeriod`
DatePeriod
`DatetimePeriod`


As you can probably guess from the names, each period corresponds to a `datetime`object and contains the same as its start and end variables.


When working with periods, each and every one of them is viewed as existing on a timeline, thus each period contains its own implementation of methods related to that position in time:


Methods like is_before, is_after and get_interim serve the purpose of comparison between periods that exist in time in a non-overlapping fashion;
Methods like `overlapped_by`, `overlaps_with`, `get_overlap` and `get_disconnect` provide the ability to work with periods that exist in time in an overlapping fashion;
Operations such as equality between periods and the in keyword allow you to determine if a period is equal to, or exists fully within, another period


Additionally, each period instance contains a Duration under its duration attribute which is built on top

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

Читать полностью…

Python Daily

D Efficient CNNs for inference

I am working on an object detection project using high resolution images.

Are there any techniques that can make a trained CNN (UNet) efficient during inference? I know pruning is one such technique, but it risks loss of accuracy and parallelizability.

/r/MachineLearning
https://redd.it/1g8kpl6

Читать полностью…

Python Daily

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/1g8cr07

Читать полностью…

Python Daily

Please help me create the perfect structure for my Flask App

I am making an URL shortener with Flask and MongoDB and just wanted to figure out the perfect project structure which follows the best practices.... I have already created this before but the structure sucks... I dont want auth right now and want to keep things modular... This is the current structure of the code:

C:.
│ .env.example
│ .gitattributes
│ .gitignore
│ botuseragents.txt
│ CODEOFCONDUCT.md
│ contributing.md
│ docker-compose.yml
│ dockerfile
│ emojies.py
│ LICENSE
│ main.py
│ pyproject.toml
│ railway.json
│ README.md
│ render.yaml
│ requirements.txt
│ vercel.json

├───.github
│ └───workflows


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

Читать полностью…

Python Daily

D Simple Questions Thread

Please post your questions here instead of creating a new thread. 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.

Thanks to everyone for answering questions in the previous thread!

/r/MachineLearning
https://redd.it/1g80nkv

Читать полностью…

Python Daily

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

Читать полностью…

Python Daily

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

Читать полностью…

Python Daily

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

Читать полностью…

Python Daily

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

Читать полностью…

Python Daily

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

Читать полностью…

Python Daily

Where i can learn docker

Hi i need to learn docker give me some resources

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

Читать полностью…

Python Daily

Configuring a Lambda to act as a Celery Worker.

Hi, i'm looking for advise on how to proper use a lambda to mimic a worker job, by using the following configuration:

AWS MQ using rabbitMQ as broker.

Lambda with configured Trigger listening on a MQ queue.

A Workflow defined in my celery app with some tasks:

task\_01: runs on a celery worker instance.
task\_02: runs on lambda, i put then on a specific queue that no other worker listen to.
task\_03: runs on a celery worker instance.

    workflow = chain(
        task_01.s(),
        task_02.s(),
        task_03.s()
)

If i execute task\_01, the lambda on task\_02 is triggered correctly, but i need to mimic celery code, save the result to the backend and trigger task\_03 correctly.

I'm currently using the code below to save the task\_02 result, but i need to make some workflow functions like chain, group, chord, to be called.

from celery.worker.request import Request

def handler(event, context):
message_data = # get the data from the

/r/django
https://redd.it/1g97dfl

Читать полностью…

Python Daily

AI-generated pictures: What do you use?

Hey guys, I'm searching for some tool/website/anything that could take my design of the Website and generate pictures similar to my branded website.

Something like train model with pictures of my website and then generate new pictures with the same fonts and colors.

Is there any simple way to do so? Thanks!

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

Читать полностью…

Python Daily

Issues with flask, uwsgi, nginx, and websockets.

I have an existing application (resume website) that is being served just fine with flask/python/uwsgi/nginx, the problem was when I tried to introduce websockets. I have read the documentation for flask socket.io in terms of deployment, not even sure if I need it, honestly I have no idea what the h3ll I am doing with the sockets. It seems like there is gevent, websocket native uwsgi, socket.io, and probably a myriad of others.

I essentially wrote a chat server backend in golang that uses rabbitmq, and i then wrote a test python script that sends messages over websockets using asyncio and websockets, this works fine.

The thought behind the project was to have an administration page be served by flask that allows the admin to see all rabbitmq queues, choose a queue, read messages from queue, and respond to queue. I could achieve this through polling directly to the backend, but I wanted to securely incoporate websockets to handle this in a secure asynchronous way being served by flask/python.

Then implement a chat modal on my resume page that allows anonymous users, to initiate chats, creating a rabbitmq queue unique to that user based on session id, admin receives new queues and messages,

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

Читать полностью…

Python Daily

Asynchronous framework for working with RabbitMQ

Hello everybody! I wrote the first version of a small (so far) framework that allows you to work with the RabbitMQ broker.

I hope that this small project can benefit people and grow into something more. The main idea is to process essays asynchronously without resorting to extending the code ring in the project. Among the nice bonuses: there is validation of field types from messages (something like what is in FastAPI, only without dependency injection).

I would like you to study my code and, if anyone has any criticism or recommendations, leave your feedback. Thank you very much!

https://pypi.org/project/aiocarrot/
https://github.com/d3nbr0/aiocarrot/

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

Читать полностью…

Python Daily

What do you do when you are frustrated?

Hi everyone!

I know this post deviates a bit from what people usually post here, but I thought it would be interesting to hear what those of you who are already developers or have code longer do with this.

How do you deal with the frustration? I'm in the phase where I haven't fully understood yet that writing code and making it actually work properly takes time, so I can get frustrated when I've been sitting for a little while and haven't found a solution yet.

Of course, what I'm doing now is just stepping away from the PC for a while and thinking about something else, but want to hear what other tips you have.

Thank you!

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

Читать полностью…

Python Daily

Live server set-up for developing with Flask?

I'm new to programming (few months in, learning in my spare time) and I've started to learn Flask to develop web apps with Python.

I'm using VSCode mostly and what I really need is for a live server type of setup so I can see the changes I'm making in HTML/CSS, as I make them. The difficulty I'm facing is that the live server plugins I've tried in VSCode don't show the results properly. E.g. they will display {{ myflaskvariable }} rather than the actual variable - which obviously makes things harder than I feel they need to be!

Everything displays fine using 'flask run' from the terminal, but I can't seem to get a live server to work the same way. Any suggestions?

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

Читать полностью…

Python Daily

Django's TechTuber?

There are Youtubers or content creators who are a reference about Django, to learn about the framework, to know the latest news?.

/r/django
https://redd.it/1g8f4xs

Читать полностью…

Python Daily

R Google Shopping 10M dataset for large scale multimodal product retrieval and ranking

We have finally released the Marqo Google Shopping 10 million dataset on Hugging Face (Marqo-GS-10M). One of the largest and richest datasets for multimodal product retrieval!

+ 10M rows of query, product title, image and rank (1-100)

+ \~100k unique queries

+ \~5M unique products across fashion and home

+ Reflects real-world data and use cases and serves as a good benchmark for method development

+ Proper data splits, in-domain, novel query, novel document and novel-document and novel query.

The dataset features detailed relevance scores for each query-document pair to facilitate future research and evaluation.

!pip install datasets
from datasets import loaddataset
ds = load
dataset("Marqo/marqo-GS-10M")

We curated this large-scale dataset as part of the publication of our training framework: Generalized Contrastive Learning (GCL).

Dataset: https://huggingface.co/datasets/Marqo/marqo-GS-10M

GCL: https://github.com/marqo-ai/GCL

Paper: https://arxiv.org/abs/2404.08535

/r/MachineLearning
https://redd.it/1g8a3pv

Читать полностью…

Python Daily

Digital ocean spaces for static file storage

I'm hosting a Django app on heroku and I want to use digital ocean spaces for serving static files. Does anyone have any insight on this? I'm pretty new to dev but really love how far I've come thanks to Django.

/r/django
https://redd.it/1g80s1k

Читать полностью…

Python Daily

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

Читать полностью…

Python Daily

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

Читать полностью…

Python Daily

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

Читать полностью…

Python Daily

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

Читать полностью…

Python Daily

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

Читать полностью…
Подписаться на канал