The a absolute high you get when you solve a coding problem.
2 years into my career that uses python. Cannot describe the high I get when solving a difficult coding problem after hours or days of dealing with it. I had to walk out one time and take a short walk due to the excitement.
Then again on the other side of that the absolute frustration feeling is awful haha.
/r/Python
https://redd.it/1ff847f
Do you have any ideas for simple Django tools?
hey all,
I decided to try my hand in creating simple tools for Django users. The first one I made is a Django Secret Generator (i know, there are many such sites out there, just trying something new, and learning django while doing it, some cur me some slack 🙈).
I'm planning to do a couple more. Here are some ideas I had:
Security checker (like, is admin page under /admin. I think there was one called django pony checker or something like that, but I'm not sure it still exists)
optimization checker (are your js and css files optimized)
I'm curious to hear from the community, if you have any ideas. Thanks a ton in advance.
/r/django
https://redd.it/1fezo43
Which Python libraries would be most suitable for Time Series Forecasts and Multilinear Regression?
I am working on a project geared towards addressing the issue of software project time estimation bias. To gather data, I'm building a work-log system that gathers info with respect to time taken to accomplish commonly-known tasks. These data will subsequently be trained using time series and multi linear regression.
Which Python libraries would be the most suitable for achieving these goals?
/r/Python
https://redd.it/1fexk8e
how do you query a certain column without including it in the route's url?
Hey guys! I'll keep this concise,
Basically I'm trying to build a mini snowflake clone, and I have have this route which takes users to a SQL query interface for the worksheet they've selected (if you've used snowflake you'll know what I mean hahah).
@users.route("/<string:username>/query/<code>", methods='GET')
@loginrequired
def query(username, code):
if username != currentuser.username:
abort(403)
# what I currently have to do
selectedworksheet = Worksheet.query.filterby(code=code)
# what I'd like to be able to do
selectedworksheet = Worksheet.query.getor404(worksheetid)
# What I want to avoid doing as it seems to add the id to the url
worksheetid = request.args.get('worksheetid', type=int)
selectedworksheet = Worksheet.query.getor404(worksheetid)
# remaining code ...
each worksheet has an id, but they also have a code so the url can look something
/r/flask
https://redd.it/1fexjlx
Typical developer processes for developing features in Flask?
As a new Flask developer, I'm curious about the typical process or checklist people work through when developing a new feature.
My current flow has been working 'inside-out' in the following order:
1. Start with the models
2. Write migrations/upgrade scripts
3. Implement the view functions
4. Set up the routes
5. Build out the templates
Is this a common or recommended approach? My thinking is that I can often add new models and db migrations, etc without breaking the working app and build from there. This seems to suit the CRUD-style app I'm developing.
Or does the development approach change depending on the feature? For example, would it be different for something more complex like a stepped process, like a bank loan application form?
If so, are there a bunch of developer process patterns I should be aware of?
/r/flask
https://redd.it/1feqqr5
Django Docker best practices for dummies?
I have created a fair few small (and one giant sprawling) Django project that are in use by small groups of consistent people (think work groups).
Up to this point, I've built sites inside python venv's and hosted with Apache mod_wsgi, all on a couple of AWS virtual machines (EC2 instances).
As I make more little Django sites, it seems like it's getting time to move into containers to keep a bit more explicit definition around package requirements/versions, transition between servers, easier local testing, etc. It seems like most tutorials out there are for toy projects on bare metal (raises hand) or using Django for Kubernetes style dynamic deployment, load balancing, etc.
Does anyone have a good resource for building / deploying relatively simple Django projects to a container for general containerization. Things like, packaging process, pros and cons of running the database in the same container / different container / bare metal, etc.
/r/django
https://redd.it/1fel39i
Why we wrote a new form library for Django
https://kodare.net/2024/09/11/why-we-wrote-a-new-form-library-for-django.html
/r/django
https://redd.it/1fe96ra
My first open-source project built with Python to inspect databases through CLI fast
What My Project Does:
peepDB is a CLI tool designed for rapid database table inspection without writing SQL. It supports MySQL, PostgreSQL, and MariaDB, allowing users to view all tables or a specific table with simple commands. The tool securely stores connection details, provides output in formatted table or JSON format.
Target Audience:
peepDB is aimed at developers debugging database-driven applications, DBAs performing quick checks or audits, data analysts exploring table structures, and those learning about databases who want an easy way to explore data. It's suitable for use in both development and production environments, providing a versatile tool for various database inspection needs.
Comparison:
peepDB distinguishes itself from alternatives by focusing solely on quick table viewing, supporting multiple databases out-of-the-box, and securely storing connection details. It requires no SQL knowledge to use, has a minimal footprint compared to larger database management tools, and offers both CLI and Python library interfaces for flexibility.
GitHub Repo: https://github.com/evangelosmeklis/peepdb
if you have any suggestions for the project or comments on how to improve let me know
/r/Python
https://redd.it/1febbx0
Live polling App using flask
https://youtu.be/uv88jm8XAmc?si=jupLOM3WXmQ3xSo_
Hi, here's a video explaining the development of live poll web app using flask framework and AJAX. MySQL database is used.
/r/Python
https://redd.it/1fe89j4
cannot import apps.views
i am developing a django app to analyze some log files and extract data and store it to the sqlite database.one of the tasks i need is to monitor a txt file where the log lines are being written by my syslog server.for the same purpose i developed a watchlog file,which will keep monitoring this file.this setup works very well in pycharm.but when i want to install the watchlog.py file as a windows service i get an error which says cannot find module.this is the import :
files is an another app in my django project.
from files.views import uploadlogfilewithoutrequest
https://preview.redd.it/wln0z8nk15od1.jpg?width=449&format=pjpg&auto=webp&s=992e6faffc122d50a8869e0c5e06aaf0820ccea5
https://preview.redd.it/yju8tvml15od1.png?width=374&format=png&auto=webp&s=d9e3939f428adbba49c99e4635a4033c1159ec32
/r/djangolearning
https://redd.it/1fe4xnz
pipefunc: Effortlessly Chain Statistical Analyses with DAG-based Pipelines
https://github.com/pipefunc/pipefunc
/r/pystats
https://redd.it/1fdutde
Wednesday Daily Thread: Beginner questions
# Weekly Thread: Beginner Questions 🐍
Welcome to our Beginner Questions thread! Whether you're new to Python or just looking to clarify some basics, this is the thread for you.
## How it Works:
1. Ask Anything: Feel free to ask any Python-related question. There are no bad questions here!
2. Community Support: Get answers and advice from the community.
3. Resource Sharing: Discover tutorials, articles, and beginner-friendly resources.
## Guidelines:
This thread is specifically for beginner questions. For more advanced queries, check out our [Advanced Questions Thread](#advanced-questions-thread-link).
## Recommended Resources:
If you don't receive a response, consider exploring r/LearnPython or join the Python Discord Server for quicker assistance.
## Example Questions:
1. What is the difference between a list and a tuple?
2. How do I read a CSV file in Python?
3. What are Python decorators and how do I use them?
4. How do I install a Python package using pip?
5. What is a virtual environment and why should I use one?
Let's help each other learn Python! 🌟
/r/Python
https://redd.it/1fdwqji
I made an app to visualize H1B visa data
Inspired by a post in another subreddit so I made this webapp in Flask. You can query and visualize data from H1B visa applications. So far I've only included roughly 9 months data there. It shows that "Web Devs" average salary is only $68k, even behind English teachers lol.
https://preview.redd.it/p6q2cqi2j1od1.png?width=901&format=png&auto=webp&s=f779706cf85a14c3684852daae12daa85974114a
https://urchin-app-qdr2l.ondigitalocean.app/by-soc-occupational-title
Still very early prototype as you can tell and don't even have a domain yet.
Really love Flask for it's simplicity and extensibility, I can see myself sticking to Flask most of time.
Happy to hear your thoughts & questions!
/r/flask
https://redd.it/1fdrx9q
A web UI for SQLAlchemy to integrate into your web apps
# What my project does
I was missing a UI to visualize my DB schema, quickly check what's in the DB, see the migrations, etc. So you know what happened next :S
I created a very simple PoC to visualize the tables and relationships of a DB, later I'm planning data visualization and alembic migrations view/management/don't know possibly some git integration to check for DB changes on other branches. The idea is to integrate the UI into your existing web application, for the moment I only support FastAPI and Starlette:pip install dbstudio
from dbstudio.fastapi import getfastapirouter
app = FastAPI()
app.mount("/dbstudio", getfastapirouter(engine))
Link to repo: https://github.com/lucafaggianelli/dbstudio
# Target Audience
The project is meant to be used during development and not in production as an admin panel or whatever
# Comparison
I was inspired by Prisma, an ORM for NodeJS that ships with its own Studio and ChartDB a tool to visualize DB schemas offline running a SQL query, I didn't find much for the SQLAlchemy world only sqladmin for FastAPI, but it doesn't show the DB schema, is more a data editor and some projects for Flask.
The alternative is to use tools like DB browser for
/r/Python
https://redd.it/1fdje37
Seasoned Developers: What does you .gitignore look like?
Help a novice out. When building with Django, what are the essentials to add to a gitignore file before pushing to remote?
/r/django
https://redd.it/1fdigtr
Semantix : Make GenAI Functions easily
### What Semantix Does
Current methods for extracting structured outputs from LLMs often rely on libraries such as DSPy, OpenAI Structured Outputs, and Langchain JSON Schema. These libraries typically use Pydantic Models to create JSON schemas representing classes, enums, and types. However, this approach can be costly since many LLMs treat each element of the JSON schema (e.g., {}
, :
, "$"
) as separate tokens, leading to increased costs due to the numerous tokens present in JSON schemas.
Semantix offers a different and more cost-effective solution. Instead of using JSON schemas, Semantix represents classes, enums, and objects in a more textual manner, reducing the number of tokens and lowering inference costs. Additionally, Semantix leverages Python's built-in typing system with minor modifications to provide meaning to parameters, function signatures, classes, enums, and functions. This approach eliminates the need for unnecessary Pydantic models and various classes for different prompting methods. Semantix also makes it easy for developers to create GenAI-powered functions.
### Target Audience
Semantix is designed for developers who have worked with libraries like Langchain and DSPy and are tired of dealing with Pydantic models and JSON schemas. It is also ideal for those who want to add AI features to existing or new applications without
/r/IPython
https://redd.it/1ff2pi5
Help with ORM query
I have 3 models: Activity, ActivityDates and ActivityAttendies. Activity has a M2M relationship with ActivityDates and ActivityAttendies has a M2M relationship with ActivityDates.
class Activity(models.Model):
FREQUENCY =
('Weekly', 'Weekly'),
('Monthly', 'Monthly')
activitydates = models.ManyToManyField('ActivityDates')
activityname = models.CharField(maxlength=200)
activityinterest = models.ForeignKey(Interest, ondelete=models.CASCADE)
additionalactivitydates = models.ManyToManyField('AdditionalActivityDates')
activityfrequency = models.CharField(maxlength=11, choices=FREQUENCY, default=None)
activitylocation = models.CharField(maxlength=200)
activitycost = models.DecimalField(maxdigits=6, decimalplaces=2)
activitystartdate = models.DateField(blank=True, null=True)
activityenddate = models.DateField(blank=True, null=True)
activityartwork = models.ImageField(uploadto='activityartwork', blank=True)
class ActivityDates(models.Model):
activitydate = models.DateField()
activityattendies = models.ManyToManyField(Person, relatedname='ActivityAttendies', through='ActivityAttendies', blank=True)
activitystarttime = models.TimeField()
activityendtime = models.TimeField()
class ActivityAttendies(models.Model):
/r/djangolearning
https://redd.it/1fexg7p
Thursday Daily Thread: Python Careers, Courses, and Furthering Education!
# Weekly Thread: Professional Use, Jobs, and Education 🏢
Welcome to this week's discussion on Python in the professional world! This is your spot to talk about job hunting, career growth, and educational resources in Python. Please note, this thread is not for recruitment.
---
## How it Works:
1. Career Talk: Discuss using Python in your job, or the job market for Python roles.
2. Education Q&A: Ask or answer questions about Python courses, certifications, and educational resources.
3. Workplace Chat: Share your experiences, challenges, or success stories about using Python professionally.
---
## Guidelines:
- This thread is not for recruitment. For job postings, please see r/PythonJobs or the recruitment thread in the sidebar.
- Keep discussions relevant to Python in the professional and educational context.
---
## Example Topics:
1. Career Paths: What kinds of roles are out there for Python developers?
2. Certifications: Are Python certifications worth it?
3. Course Recommendations: Any good advanced Python courses to recommend?
4. Workplace Tools: What Python libraries are indispensable in your professional work?
5. Interview Tips: What types of Python questions are commonly asked in interviews?
---
Let's help each other grow in our careers and education. Happy discussing! 🌟
/r/Python
https://redd.it/1fep0y6
PayPal vs. Stripe for Django Donations: Which Payment Gateway is Best for a Charity Site?
I’m building a charity website where the admin can manage content and handle donations. Historically, the client used PayPal for donations, but I’m considering using Stripe instead, given the better-maintained Django modules for Stripe.
Has anyone implemented both in a Django project? Which would be more straightforward for maintaining a reliable donation system? Any advice on pros/cons of sticking with PayPal vs. switching to Stripe for this use case?
/r/django
https://redd.it/1fefwpv
SEO in django
Hello, im next to build a tiny website with django and im going to deploy it. I've thinking if there is a way to configure the ceo tags with django or if i have to do it manualy.
Sorry if isn't related to django and i would be very grateful if somebody can give some advices with this.
/r/django
https://redd.it/1fevex2
how to scale a system to handle millions of concurrent updates on the backend?
i was recently asked an interview question how i would scale an architecture currently consisting of 3 boxes (a web server, a frontend, and a backend) in order to handle millions of updates to the inventory field in the database?
this could be an ecommerce website where thousands of concurrent users come in to
purchase their items 24x7 and as such the inventory field is updated constantly
and every second of the day.
the question asked was what change or an additional box i would add to scale the
current architecture containing 3 boxes so that the latest and updated
inventory information can be accessed via APIs with low latency?
note that this question is in the the same context i asked another question here couple of
days ago about the inventory data.
in this post i wanted to lay out the exact scenario what was asked by the interviewer as i am still
puzzled if another box or change in the current architecture would be necessary. i think with various cache options available today (e.g. redis etc. which was my answer) there shouldn't be a need to add an additional box but the interviewer didn't think
/r/flask
https://redd.it/1feo261
Integrating Stripe with Flask: A Step-by-Step Tutorial
I recently put together a beginner-friendly tutorial on how to integrate Stripe into your Flask application. If you're looking to implement payment processing but feel a bit overwhelmed, this guide breaks down the steps in a straightforward manner.
One of the key aspects of the tutorial is setting up user authentication to manage payments and subscriptions securely. We cover everything from user registration and login processes to implementing Stripe subscriptions and webhooks for handling payment events.
Additionally, you'll find snippets of code provided, which you can use as a handy template. By the end of it, you'll be equipped to start monetizing your Flask app with Stripe.
Here's what you can expect from the post:
- Setting up Stripe and your Flask app environment.
- Implementing user authentication using Flask-Login.
- Creating a checkout session for subscriptions.
- Handling webhooks to update subscription status in your database.
- Differentiating between free and premium content based on user subscriptions.
You only need a Stripe account to get started. For anyone interested, check out the full guide here: Integrating Stripe with Flask
/r/flask
https://redd.it/1fdzhr7
Migrations
My company is making something i think it's stupid,
They don't track migrations with git, and in every environment stage, prod, local
They make migrations and migrate with every push
And every environment have different files
Is that fuckin normal, or this company is a shit? Cause i feel like I'm stupid
/r/django
https://redd.it/1fe603z
Implementing Python Bindings for Dust DDS with PyO3
Hi everyone! 👋
I recently wrote an article for my company on how we created Python bindings for our native Rust implementation of the Data Distribution Service (DDS) middleware, called Dust DDS.
While the article isn't exclusively about Python, it dives deep into the process of using PyO3 for binding Rust to Python, going through the design decisions we made and how we programmatically generate the pyi file from the original Rust API. I thought it might be helpful or inspiring for anyone looking to bridge Rust and Python in their projects so you can check it out here: https://www.s2e-systems.com/2024/09/11/dust\_dds\_python\_bindings/
/r/Python
https://redd.it/1fe4w3m
Ive been working with Django professionally for a couple years now so Ive decided to make my home office more comfy!
/r/django
https://redd.it/1fdvkv0
Dict Hash: Efficient Hashing for Python Dictionaries
# What My Project Does
Dict Hash is a Python package designed to solve the issue of hashing dictionaries and other complex data structures. By default, dictionaries in Python aren’t hashable because they’re mutable, which can be limiting when building systems that rely on efficient lookups, caching, or comparisons. Dict Hash provides a simple and robust solution by allowing dictionaries to be hashed using Python’s native hash function or other common hashing methods like sha256
.
It also supports hashing of Pandas and Polars DataFrames, NumPy arrays, and Numba objects, making it highly versatile when working with large datasets or specialized data structures. Of course, the package can hash recursively, so even dictionaries containing other dictionaries (or nested structures) can be hashed without trouble. You can even implement the Hashable
interface and add support for your classes.
One of the key features of Dict Hash is its approximated mode, which provides an efficient way to hash large data structures by subsampling. This makes it perfect for scenarios where speed and memory efficiency are more important than exact precision while maintaining determinism, meaning that the same input will always result in the same hash, even when using approximation. Typically we use this when processing large
/r/Python
https://redd.it/1fdkpkz
Best Django Courses
I am a Senior Frontend Developer with +7 years. The company I am already working has a Tech Stack with Django.
One of my mission is getting certificate related to our tech stack. I want to learn Django with advanced backend concepts because it is opportunity for me.
I know that the best way to learn a new technology is reading and applying the docs. But my company rule is collecting certificate as well.
What are your suggestions in this point? Which courses do you suggest to me? Thanks in advance 🖖
/r/django
https://redd.it/1fds72q
django-allauth has been moved over from Microsoft GitHub to Codeberg
https://codeberg.org/allauth/django-allauth
/r/django
https://redd.it/1fdq4rq
Calorie Counter Website
https://caloriecounter.pythonanywhere.com
/r/flask
https://redd.it/1fdlkds
Issue: Microsoft SSO Integration State Mismatch (Django + Azure App Service)
I’m working on integrating Microsoft SSO into my Django app (hosted on Azure App Service). The SSO login flow seems to work up to the point where the callback is received, but I’m consistently encountering a "State Mismatch" error. I’ve tried multiple solutions, and I’m hoping someone could help me resolve this issue.
# Django & Azure Configuration:
Django version: 5.0.6
Python version: 3.12
SSO Integration Package: `django-microsoft-sso`
Azure App Service: Hosted with App Service Plan for deployment.
Time Zone: Central Time (US & Canada) on local development and UTC on the Azure server.
Session Engine: Using default Django session engine with database-backed sessions (django.contrib.sessions.backends.db
).
ERROR 2024-09-09 14:12:40,723 - State Mismatch. Time expired?
INFO "GET /microsoft_sso/callback/?code=... HTTP/1.1" 302 0
DEBUG views Login failed at 2024-09-09 19:xx:xxpm: Displaying login_failed page.
DEBUG views Session ID during login_failed: None
DEBUG views Session contents during login_failed: {}
DEBUG views CSRF token during login_failed: None
SSO Callback Code:
import logging
import os
import binascii
from django.contrib.auth import login
from django.shortcuts import redirect, render
from django.urls import reverse
from django.conf import settings
from django.contrib.auth.models import User
from django.utils.timezone import now
logger = logging.getLogger(__name__)
def microsoft_sso_callback(request):
logger.debug(f"Start Microsoft SSO login. Current Server Time: {now()}")
# Retrieve the state from the callback and session
state = request.GET.get('state')
session_state = request.session.get('oauth2_state')
logger.debug(f"Received state in callback: {state}")
logger.debug(f"Session state before validation: {session_state}")
logger.debug(f"Session ID during callback: {request.session.session_key}")
logger.debug(f"Session contents during callback: {dict(request.session.items())}")
#
/r/djangolearning
https://redd.it/1fd83fu