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
Trouble getting registration form to submit with first_name and email

I have a template from creative-tim. I am trying to get my registration form to work so it will input first\_name and email. Everything else is submitting perfect fine.

templates/registration/signup.html snippet

<form method="POST" action="{% url 'signup' %}">
{% csrf_token %}
<div class="mb-3">
<label for="id_first_name" class="form-label">First Name</label>
{{ form.first_name.errors }}
<input type="text" name="first_name" id="id_first_name" class="form-control bg-gradient-dark border-dark text-white" placeholder="First Name" aria-label="First Name">
</div>


/r/djangolearning
https://redd.it/1dm1als
discover-plugins - track which plugins are installed into your python environment

# What my project does

discover-plugins is a simple CLI tool that lets you list and filter ~~plugins~~ entrypoints installed into a python environment.

I recently had to track down a bug that I ultimately resulted from a plugin I had installed into my environment. To my surprise, there was no easy way to list which kind of plugins were installed, so I decided to build my own tool.

# Target Audience

discover-plugins is intended as a debugging tool for those times when you are not quite sure which plugins are currently part of your python environment.

# Installation

pipx install discover-plugins

# Usage

Find all installed plugins related to pytest (the relevant group name is pytest11):

discover-plugins --group pytest11

The tool defaults to use the first python interpreter on your path, you can optionally specify which interpreter to use with the --interpreter flag.

The output will list all entrypoints belonging to the pytest11 group. For example, if you had installed a single pytest plugin (pytest-aws-apigateway) the output would look like this:

{
"pytest11":
{
"name": "pytest_httpx",


/r/Python
[https://redd.it/1dm01o1
How to Quantitatively Measure the Accuracy of RAG Model-Generated Answers Compared to Expert Respons

Hi everyone,

I’m working on a project that involves generating answers to a set of frequently asked questions (FAQs) related to dental sciences using a Retrieval-Augmented Generation (RAG) model. To evaluate the performance of the RAG model, I want to quantitatively measure the accuracy of its answers compared to standard answers provided by dental professionals and doctors.

I have both sets of answers (expert and RAG-generated) for the same questions, and I’m looking for effective methods or metrics to compare them

/r/Python
https://redd.it/1dm5r6y
Is anyone here looking for a developer to contribute to your personal projects?

I guess the title explains it all, I'm looking for some personal projects to work or contribute on and would be really helpful if anyone is looking for a dev. I did look upon some open-source projects but they were too advanced and out of scope for me so I just wanna start small and learn.

/r/Python
https://redd.it/1dm4h72
Pulling Current List From Database in Flask-Admin Form

`Hello guys,`

1) I have a database named Account and I want to list the Account records of the current user in a select list in this database. But this list must be up to date and list all Accounts currently available. But the code I wrote does not work that way. For example, I add an Account, but I have to close and reopen the script for it to appear up to date. if I don't do this the accounts are never listed. How can I solve this problem?

2) I want to show error/warning or success message on the form depending on the situation. What code can I do this with? I tried form.errors\['general'\] but I was not successful.



I would be very glad if you could help me, thank you.

Screenshot of code : https://imgur.com/carbon-5PSK9Kz


`class JobView(MyModelView):`

`column_list = ('id', 'user_id','account_name', 'api_key', 'keyword_list', 'instructions', 'language', 'product', 'search_tweet_limit', 'num_tweets', 'sleep_time')`

`form_columns = ['account_name', 'api_key', 'keyword_list', 'instructions', 'language', 'product', 'search_tweet_limit', 'num_tweets', 'sleep_time']`



`form_choices = {`

`'account_name': [], # Boş bırakıyoruz, dinamik olarak dolduracağız`

`'language': [], # Boş bırakıyoruz, dinamik olarak dolduracağız`

`'product': [('Latest', 'Latest'), ('Top', 'Top')]`

`}`



`def on_model_change(self, form, model, is_created):`

`if is_created:`

`model.user_id = current_user.id`

`super(JobView, self).on_model_change(form, model, is_created)`



`def is_accessible(self):`

`return current_user.is_authenticated`



`with app.app_context():`

`accounts = Account.query.all()`

`for account in accounts:`

`form_choices['account_name'].append((account.auth_info_1, account.auth_info_1))`



`languages =

/r/flask
https://redd.it/1dm4513
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/1dm9767
My library VidGear v0.3.3 - brings libcamera API Support to python.

Hello Python developers!

I'm excited to announce the release of VidGear v0.3.3, which brings official support for the libcamera backend in its PiGear API! This update enhances the capabilities of Raspberry Pi Camera Modules and provides limited USB camera support.

#### More about PiGear:

PiGear is a specialized API optimized for Raspberry Pi 🍇 Boards, offering comprehensive support for camera modules (e.g., OmniVision OV5647 Camera Module, Sony IMX219 Camera Module) and limited compatibility for USB cameras.

PiGear implements a seamless and robust wrapper around the Picamera2 Python library, simplifying integration with minimal code changes and ensuring a smooth transition for developers already familiar with the Picamera2 API. PiGear leverages the libcamera API under the hood with multi-threading, providing high-performance 🔥, enhanced control, and functionality for Raspberry Pi camera modules.

PiGear handles common configuration parameters and non-standard settings for various camera types, simplifying the integration process. PiGear currently supports PiCamera2 API parameters such as sensor, controls, transform, and format, with internal type and sanity checks for robust performance.

While primarily focused on Raspberry Pi camera modules, PiGear also provides basic functionality for USB webcams (only with Picamera2 API), along with the ability to accurately differentiate between USB and Raspberry Pi cameras using metadata.

PiGear seamlessly switches to

/r/Python
https://redd.it/1dmfnzv
Does anyone follow the Fat Model, Skinny View design pattern in real-world projects?

We're currently dealing with some very thick views at work (think legacy startup code, lol), and I'd like to establish a convention to avoid this in the future. I've found a few resources that recommend encapsulating business logic in your models.

While I'm considering the 'Fat models, skinny views' approach, I'm also curious about any potential pitfalls or challenges that might come with it.

Could you share any insights or experiences in this regard?

Thanks in advance!

References:
- Official docs: https://docs.djangoproject.com/en/5.0/misc/design-philosophies/#include-all-relevant-domain-logic
- Best practices site I found: https://django-best-practices.readthedocs.io/en/latest/applications.html#make-em-fat

/r/django
https://redd.it/1dlxhg3
I've created artikle (https://artikle.live/), an app that classifies LinkedIn posts based on various topics—I've currently set it up for tracking store openings. It's fully built with Flask and Dash. All done in a couple of days. Flask is a really powerful and simple framework.




/r/flask
https://redd.it/1dm2q4s
How can I integrate a existing django project into a django ui kit?

Hey guys....i have joined a startup..and they have 2 things
1. A django project with some models and html templates where i can input data ...
2. A django ui kit...
Now they want me to integrate the main project into the ui kit...
How can i do this?
Is there any way to do this via API?
If so, then how to do this?

/r/djangolearning
https://redd.it/1dmhdrs
Understanding someone else's code

I'm interning right now and have been handed over an unfinished django project by the company. how do i begin to try understanding it ? is there a method that experienced devs use ? the proj does have a postman collection but no other documentation as such. My question might be a little ignorant but i just need to be pointed in the right direction.

(the project isn't live right now, they've just given me push access on github)

/r/django
https://redd.it/1dmhoqh
Python(Django) vs JS(MERN) vs Java

I'm currently a 2nd-year college student with a 2-month vacation right now. I'm planning to dive into web development during this break and throughout my 2nd year. I’d appreciate some advice on my roadmap and whether it’s optimized for my goals.



Here's my current plan:



**2nd Year:**

- **Summer (2 Months)**:

- **Backend**: Learn Django (I already know Python).

- **Frontend**: Learn React.

- **Academic Year**:

- Continue with Django and React.

- Learn FastAPI for building high-performance APIs.

- Focus on Java for DSA (since my college curriculum includes Java).



**3rd Year:**

- **College Curriculum**: Focus on Python for AI/ML projects with Django(heard django is good for this)

- **Self-study**: Switch to the MERN stack (MongoDB, Express.js, React, Node.js) ( Bcoz it is more performant)



**4th Year:**

- **Web Development**: Gain proficiency in both Python (Django, FastAPI) and the MERN stack.

(MAYBE TRY) - **App Development**: Learn React Native or Flutter.



My questions are:

1. Is this roadmap feasible and efficient for becoming proficient in development?

2. Should I prioritize Django and FastAPI over the MERN stack, or vice versa?

3. Given that big companies often use Java and startups lean towards the MERN stack, how should I balance my learning focus?

4. Any other tips or suggestions to

/r/django
https://redd.it/1dmogee
I want to build my first SaaS.

Hey all!
So, I've been a django developer for about 2 years and now I want to build my first SaaS, any advice on how to get started? I don't have any experience on how to put a website to production and I think that's something I'll need to learn along the way.
Stuff like load balancing also scare me cause I'm a self-taught programmer and I'm always afraid of forgetting something or writing shitty code. Besides, I don't have any front-end development knowledge so I think I'm gonna be using django's templates to build the front-end. Is this a stupid idea?
Any help is extremely appreciated :D

/r/django
https://redd.it/1dmwhha
Django and Reactjs

Hi everyone,

Just an update that I've been working on an exciting side project that combines Django and ReactJS!

🌟 Project Highlights:Seamless Integration: Leveraging Django's robust backend capabilities with React's dynamic frontend features.
Responsive Design: Ensuring a smooth and intuitive user experience across all devices.
Scalable Architecture: Building a solid foundation that can easily grow with additional features.

💡 Learning & Growth: This project has been an good learning journey, allowing me to deepen my understanding of full-stack development and modern web technologies. It has also given me hands-on experience with RESTful APIs, state management, and component-based design.

📈 Future Plans: I'm looking forward to adding more features, optimizing performance, and maybe soon will drop a demo.

https://preview.redd.it/c9o1qjj9oc8d1.png?width=1366&format=png&auto=webp&s=62d0fbf5f5edf7d85e9deb10c0cfc0a0cd5315bc

https://preview.redd.it/pl8h5xj9oc8d1.png?width=1366&format=png&auto=webp&s=63b904b10480a3d2233321aa7a22063e98c77f5a

https://preview.redd.it/7urmdyj9oc8d1.png?width=1366&format=png&auto=webp&s=4d861c06f249e72d7b416555f798f972884154ef

https://preview.redd.it/8268lrm9oc8d1.png?width=1366&format=png&auto=webp&s=13e27b4beb7e28b0bb3f3739dc11c42922ecc104



/r/django
https://redd.it/1dmqcdq
Python Polars 1.0.0-rc.1 released

After the 1.0.0-beta.1 last week the first (and possibly only) release candidate of Python Polars was tagged.

1.0.0-rc.1 release page: [https://github.com/pola-rs/polars/releases/tag/py-1.0.0-rc.1](https://github.com/pola-rs/polars/releases/tag/py-1.0.0-rc.1)
Migration guide: https://docs.pola.rs/releases/upgrade/1/

About Polars

Polars is a blazingly fast DataFrame library for manipulating structured data. The core is written in Rust, and available for Python, R and NodeJS.

Key features

Fast: Written from scratch in Rust, designed close to the machine and without external dependencies.
I/O: First class support for all common data storage layers: local, cloud storage & databases.
Intuitive API: Write your queries the way they were intended. Polars, internally, will determine the most efficient way to execute using its query optimizer.
Out of Core: The streaming API allows you to process your results without requiring all your data to be in memory at the same time
Parallel: Utilises the power of your machine by dividing the workload among the available CPU cores without any additional configuration.
Vectorized Query Engine: Using Apache Arrow, a columnar data format, to process your queries in a vectorized manner and SIMD to optimize CPU usage.

/r/Python
https://redd.it/1dmmqmn
Django + Pgvector + LLMs = Semantic Search and AI Agent Powered Document Analytics

Hi, folks, sharing my latest open source Django project to experiment with Django-powered document analytics tools. I've worked on OpenContracts for a number of years now. While it started out as a tool to label and annotate documents, thanks to the recent advances in LLMs and vector databases, I've released a new version with a bunch of cool features to use LLMs, vector search and AI Agents. It keeps amazing me how Django keeps getting more and more capable with age!

I had to share!

Some Screen Captures:

You can upload documents and they're automatically parsed by layout and their vector embeddings are stored in Django via pgvector

Data extracted from documents is traceable back to the source in the document

Key Features:

1. Manage Documents - Manage document collections
2. Layout Parser - Automatically extracts layout features from PDFs
3. Automatic Vector Embeddings - generated for uploaded PDFs and extracted layout blocks
4. Pluggable microservice analyzer architecture - to let you analyze documents and automatically annotate them
5. Human Annotation Interface - to manually annotated documents, including multi-page annotations.
6. LlamaIndex Integration - Use our vector stores (powered by pgvector) and any manual or automatically annotated features to let an LLM intelligently answer questions.
7. Data Extract - ask multiple questions across hundreds of documents using complex

/r/django
https://redd.it/1dn1exe
Flask Mega Tutorial Migration problems

I'm following the 2023 Flask Mega Tutorial and I can't get the migration portion to work for me.

I don't want to use sqlite, so I have an AWS RDS for MySQL instance running and have confirmed that I can connect to it. I can make changes and run queries via MySQL Workbench. But no matter what I do I can't get flask migrate to see the models I'm defining and make the changes. The flask db init command works fine.

models.py

\_\_init\_\_.py

Anyone have any insight? I'm pulling my hair out trying to solve this.

/r/flask
https://redd.it/1dmzswg
Admin panel no longer synced with friend

I’m working on a project with a friend, and our admin panel would usually be synced. For example, if they made a superuser, then it would show up under Users on my admin panel and vice versa. However, I was working on the project today and realized our databases weren’t synced anymore, and it was causing issues in the project. Any general idea why this could happen and how to fix it?

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