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
Flask Deployment on AWS ECS

Hello! I have a fitness application that has around 3000 daily active users. Now, I want to scale it horizontally and I want to deploy it on AWS ECS and I am facing trouble with security groups, services, rules. Basically, I have never deployed on AWS before. Now, I want to deploy it on short notice for production. So, Kindly share any quick related helpful tutorial or guide. Thanks!
PS: Currently It’s on digital ocean droplet and I have created docker image already and uploaded on amazon elastic registry. Image runs well on local. I have attached RDS with it. Having trouble connecting to Document Cluster.

/r/flask
https://redd.it/1c3rbzh
Is Litestar production ready 2024?

At least a couple things that seems is that Litestar appears to be a fast Django lite. Some batteries included, but not too many and opinionated. It's uses Rust so of course it's going to be fast, not that it really matters that much since IO > CPU for a website IMO. Which any async framework addresses this.

I haven't heard many people using it though despite it having a lot of batteries included, but not dominating everything with first party support. Anyone using it in production in 2024?

Edit:

Fact check it appers it isn't written in Rust, I probably confused it with something else or it might just be data serialization

/r/Python
https://redd.it/1c3irsc
I am struggling to create relationship table using flask_sqlalchemy. please help.

/r/flask
https://redd.it/1c3ywth
D Advice for spotting "fake" ML roles?

I recently got hired for what turned out to be a fake ML role even by the loosest definition of an ML role (Bloomberg AI group). It seems like currently there are many companies/teams/people who pretend to do ML work and when it comes to hiring they lie to candidates about the work they actually do. Does anyone have any strategies to spot these kinds of roles so they can be avoided? It seems like asking questions during the interview is not very effective because you could easily just be lied to.

/r/MachineLearning
https://redd.it/1c3z8ug
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/1c486f4
I have a few question about flask-admin . More details on the questions are located below.

Here is the folder of the code I created to test flask admin

[https://file.io/ESGtJaHOw4Di](https://file.io/ESGtJaHOw4Di)

Here is the docs on flask admin

[https://flask-admin.readthedocs.io/en/latest/introduction/](https://flask-admin.readthedocs.io/en/latest/introduction/)

Why does the code blocks below not work in my flask-admin?

column_exclude_list = ['id']
column_editable_list = ['body', 'title']

I commented the code below because of error, this also is not working.

inline_models = ['Post,']
can_export = True

Is there an easier way then using this to make flask-wtf forms work?'



I assume if I use “Working With the Built-in Templates” part of the documentation of flask-admin I don't have to use the code below to make flask-wtf forms work. Is this correct ?



form_args = {
'id': {
'label': 'Include id',
'validators': [DataRequired()]
}
}



Also I am little confused by what [https://flask-admin.readthedocs.io/en/latest/introduction/#available-template-blocks](https://flask-admin.readthedocs.io/en/latest/introduction/#available-template-blocks) are ?

I assume they are just a way of overriding the HTML files in admin template, is that correct?

Also I assume [https://flask-admin.readthedocs.io/en/latest/introduction/#generating-urls](https://flask-admin.readthedocs.io/en/latest/introduction/#generating-urls) allows you to link to URL in the admin.

When would this be useful?







/r/flask
https://redd.it/1c47121
Best starter kit stream update: Tomorrow, we're integrating payments

Hey all!


This is an update post on the community live streams. If you're new to that, I asked about interest in developing a full SaaS product on a live stream last November and have recently picked up streaming again.


Our current project is creating the *best* django starter kit together. During the two streams last week, we added multi-tenancy to the application. It took two streams because I was explaining everything in much detail and also talked a lot about different business aspects. If you want to re-watch (parts of) those streams, they are available as VoDs.


So far, I've streamed for over 44 hours for community education and want to thank each and every one for participating and interacting. It really brings me a lot of joy and is the reason why I'm doing this.


As I have outline in my recent blog post, the progress is as intended, and in about 12 hours, I will stream the research and integration of a payment provider to handle one time payments, and subscriptions. Not just code, but a business-focused research and discussion about which of all the many option to choose from. If you want to join, the link to the event on

/r/django
[https://redd.it/1c42d8p
Tracking users entries into views

I'd like to track how often a particular user enters in to different views to see which portions of my site are getting the most traffic and which ones are being repeated multiple times by the same user. I thought of two ways to do this.

1. Each time a user enters a view log that into the user model
2. Each time a user enters a view log it into a text file that gets automatically uploaded daily.

Not sure if there are other ways that are better. My goal is to minimize the amount of time so the user isn't getting held up. I'm concerned that putting it directly into the database each time would be time consuming but if it would be about the same as the second option then I'm happy to do that. But wanted to reach out to people and see if they had any opinions on this.

/r/django
https://redd.it/1c3xqat
Art Gallery application with Hotel Booking. Should I create 2 databases or one database?

I am creating a website for an Art Gallery. I should then add a hotel booking functionality for the art gallery visitors. How should that be done in Flask? Create the tables for the art gallery and hotel booking in the same database or create a database for the art gallery and a database for hotel booking in one application and separate the tables using binds e.g

app.config['SQLALCHEMY_BINDS'] = {
'second_db': 'sqlite:///C:\\Users\\abc\\DB Browser for SQLite\\hotels.db'
}

​

/r/flask
https://redd.it/1c4gtk8
issue changing DateTimeField to DateField in model

Hi,

in my model class, I changed a field/column from DateTimeField to DateField.

New records are stored with correct Date values, but existing records still have the Time values:

6|2023-09-08 16:00:00|2|1||26|25
2|2023-09-08|2|1||26|25

When loading data, older records come with Null Date. It seems DateField fails to load the date if there is also a Time part.
DB is Sqlite. Any suggestion?

/r/django
https://redd.it/1c4kufw
Issue with my React and Admin UI using the same session cookie

Hey guys,

I've only picked up Django a few months ago but we do have a live production application running.

We use Django Admin for staff logins to do some data manipulation and we have a React Frontend for Client logins.

The issue that we have is that if we log into both the React app the Admin panel on the same browser the session cookie is shared, so which ever user was logged in latest is used across both sites.

They are both hosted on the same domain, our admin panel at test.mydomain.com and my React UI at test-app.mydomain.com.

Is it possible to have different users be logged into the different UIs without the cookies overriding each other?

/r/django
https://redd.it/1c4m5eg
How good are Django templates?

I'm aware most devs use Django for the REST Framework, but I'm curious to know from more experienced devs, When do you decide to use Django templates over REST Framework and a JS frontend framework like React or something?


/r/django
https://redd.it/1c4nqoh
How fast can Python parse 1 billion rows of data? (1brc)

https://www.youtube.com/watch?v=utTaPW32gKY

I made a video summarizing the top techniques used by the Python community in the recently popular One Billion Row Challenge (1brc, https://github.com/gunnarmorling/1brc).

I adapted one of the top Python submissions into the fastest pure Python approach for the 1brc (using only built-in libraries). Also, I tested a few awesome libraries (polars, duckdb) to see how well they can carve through the challenge's 1 billion rows of input data.

If anyone wants to try to speed up my solution, then feel free to fork this repo https://github.com/dougmercer-yt/1brc and give it a shot!

/r/Python
https://redd.it/1c4ln3x
Announcing pixi-kernel - Jupyter kernels using Pixi for reproducible notebooks

# What My Project Does?

Hello everyone, I'm proud to announce a brand-new Python library named pixi-kernel: https://github.com/renan-r-santos/pixi-kernel allowing you to run Jupyter kernels using Pixi for reproducible notebooks.

By the way, if you haven't heard of the Pixi package manager, check it out at https://pixi.sh/latest/.It supports conda and PyPI (through uv) packages, pyproject.toml config, git, path and editable installs and it is really fast.

# Target Audience

JupyterLab users, production-ready.

# Comparison

The main differences compared to similar solutions such as poetry-kernel are the ability to install conda-forge packages and using kernels in languages other than Python. Compared to nb-conda-kernels, the difference is the use of the Pixi package manager which allows per-directory dependency locking.

/r/Python
https://redd.it/1c4rxel
Meta Used Monolithic Architecture Using Python to Ship Threads in Only Five Months

https://www.infoq.com/news/2024/04/meta-threads-instagram-5-months/

Zahan Malkani talked during QCon London 2024 about Meta's journey from identifying the opportunity in the market to shipping the Threads application only five months later. The company leveraged Instagram's existing monolithic architecture, written in Python and PHP, and quickly iterated to create a new text-first microblogging service in record time.

/r/Python
https://redd.it/1c4u5ml
Looking for a ‘flask’ consultant

Hi all,

I have a flask app deployed on my current server (business hosting shared) and it works great when only one user is using it but it seems like when multiple people are using the app it surpasses my servers resources.

It does not seem like scaling the server is feasible and i want to scale the app.

The context of the app is simple, it’s taking data from my data base and rendering images. The app then takes the rendered images and spits out pixel data in json format.

I don’t have a ton of experience in this realm of things - hoping to meet someone who does and pay you for your time.

please Dm me or post here!

/r/flask
https://redd.it/1c4sdvs
Announcing pixi-kernel - Jupyter kernels using Pixi for reproducible notebooks

Hello everyone,

I'm proud to announce a brand-new Python library named pixi-kernel. Feedback and suggestions are welcome.

https://github.com/renan-r-santos/pixi-kernel

Also, if you haven't heard of the Pixi package manager, check it out at https://pixi.sh/latest/.

It supports conda and PyPI (through uv) packages, pyproject.toml config, git, path and editable installs and it is really fast.

/r/IPython
https://redd.it/1c4l2k2
Some days I really love python...

I have a problem that I was terrible at listening to new music, everything I listen to is from around 2000 - 2010.

There is a radio station here in the UK called BBC 6 music that has a decent playlist but since I only really listen in the car its not always appropriate to note the track names down - and my memory is terrible so I always forget by the time I get home.

Luckily they put the playlist online but it's just text links so I can't add it to my music service of choice - YouTube Music.

Thankfully the page is pretty simple so I wrote a basic ass scraper that will grab the HTML, parse through the tracks with beautful soup, then use the ytmusicapi package to remove the old tracks from my playlist and recreate it with the freshly scraped data, railway then makes it dead easy to deploy and schedule it to run once a day.

This thing took me probably less than an hour and a half to create and will hopefully open me up to some quality new tunes!

/r/Python
https://redd.it/1c4wsmn
Diffusion versus Auto-regressive models for image generation. Which is better? D R

Hello all,

I am new to this field of image generation using transformer models. I am curious about the above two mentioned approaches. Particularly in light of this paper "Visual Autoregressive Modeling: Scalable Image Generation via Next-Scale Prediction" (results). It looks like these AR (auto-regressive) models seem to be better especially when scaled up compared to DiTs (Diffusion Transformers). Their main inference benefits seem to come from the low sampling efficiency of DiT.

However, I have my doubts regarding this. Apart from the fact that major AI powerhouses have adopted diffusion models, there is a solid theory backing diffusion models being capable of generating any image distribution. Apart from that, there are no results of the above VAR paper for small models (something I am also interested in).

So here are my questions:

1. Are there any DiT distillation papers which improve the sampling efficiency? I could not find any transformer ones, all were U-Net based.
2. Is there any theory backing AR transformer models for image generation (or for any generative task for that matter)?
3. Is this VAR paper better purely because people haven't yet explored DiT well enough? Or AR model supremacy is what is expected?
4. If you were to pick between the

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