Python as a Configuration Language Using Starlark
I wrote an article about how Pythonic syntax (using Starlark) helps avoids many of the configuration related challenges seen with YAML and other such languages. Let me know any feedback.
/r/Python
https://redd.it/1o8gd22
I wrote an article about how Pythonic syntax (using Starlark) helps avoids many of the configuration related challenges seen with YAML and other such languages. Let me know any feedback.
/r/Python
https://redd.it/1o8gd22
OpenRun - App Deployment Simplified
Python as a Configuration Language Using Starlark
Experience with using Starlark (which has a Pythonic syntax) for most configuration needs in OpenRun.
Automating your heating with Octopus Energy AGILE tariff
Hi all, I've just made a Python tutorial for how you can automate your electric heaters during the Agile Energy Plunge Pricing, in the UK.
Effectively, we're automatically switching on our smart plugs (electric radiators), when the price of electricity is negative. This results in consistent credit back every time there's an Octopus Energy Plunge Pricing, plus a nice warm home.
You just need Tapo smart plugs and a Raspberry pi.
https://youtu.be/ch-9DpZL6Vg
code:
https://github.com/yojoebosolo/AutoHeating/
Hope it's helpful to some of you.
/r/Python
https://redd.it/1o86j5t
Hi all, I've just made a Python tutorial for how you can automate your electric heaters during the Agile Energy Plunge Pricing, in the UK.
Effectively, we're automatically switching on our smart plugs (electric radiators), when the price of electricity is negative. This results in consistent credit back every time there's an Octopus Energy Plunge Pricing, plus a nice warm home.
You just need Tapo smart plugs and a Raspberry pi.
https://youtu.be/ch-9DpZL6Vg
code:
https://github.com/yojoebosolo/AutoHeating/
Hope it's helpful to some of you.
/r/Python
https://redd.it/1o86j5t
YouTube
Get paid to heat your home - Python Tutorial
This is the full breakdown and Python tutorial for how to get paid to heat your home using Octopus Energy AGILE tariff, Tapo smart plugs and a Raspberry pi.
Effectively, we're automatically switching on our smart plugs (electric radiators), when the price…
Effectively, we're automatically switching on our smart plugs (electric radiators), when the price…
D For people who work (as PhD students) in Mila, Quebec, what your experience have been like?
You may know that Mila in Quebec is opening applications for PhD students recently, and I am considering for applying. I have searched relevent key words here, but it seems that there are not so many recent posts on studying and working experience at Mila, so I was wondering how do you like your experience here and/or in Montreal in general? For instance, how do you like your work-life balance, Montreal's winter/weather aspects, supervisors? To be more specific, I am interested in DL/LLM theory, AI / foundational models for (formal) math (e.g., Goedel-Prover-V2), and/or post-training.
Thank you!
/r/MachineLearning
https://redd.it/1o81qlw
You may know that Mila in Quebec is opening applications for PhD students recently, and I am considering for applying. I have searched relevent key words here, but it seems that there are not so many recent posts on studying and working experience at Mila, so I was wondering how do you like your experience here and/or in Montreal in general? For instance, how do you like your work-life balance, Montreal's winter/weather aspects, supervisors? To be more specific, I am interested in DL/LLM theory, AI / foundational models for (formal) math (e.g., Goedel-Prover-V2), and/or post-training.
Thank you!
/r/MachineLearning
https://redd.it/1o81qlw
X (formerly Twitter)
Mila - Institut québécois d'IA (@Mila_Quebec) on X
Mila's annual supervision request process is now open to receive MSc and PhD applications for Fall 2026 admission! For more information, visit https://t.co/r01eLcY1P4
Friday Daily Thread: r/Python Meta and Free-Talk Fridays
# Weekly Thread: Meta Discussions and Free Talk Friday 🎙️
Welcome to Free Talk Friday on /r/Python! This is the place to discuss the r/Python community (meta discussions), Python news, projects, or anything else Python-related!
## How it Works:
1. Open Mic: Share your thoughts, questions, or anything you'd like related to Python or the community.
2. Community Pulse: Discuss what you feel is working well or what could be improved in the /r/python community.
3. News & Updates: Keep up-to-date with the latest in Python and share any news you find interesting.
## Guidelines:
All topics should be related to Python or the /r/python community.
Be respectful and follow Reddit's Code of Conduct.
## Example Topics:
1. New Python Release: What do you think about the new features in Python 3.11?
2. Community Events: Any Python meetups or webinars coming up?
3. Learning Resources: Found a great Python tutorial? Share it here!
4. Job Market: How has Python impacted your career?
5. Hot Takes: Got a controversial Python opinion? Let's hear it!
6. Community Ideas: Something you'd like to see us do? tell us.
Let's keep the conversation going. Happy discussing! 🌟
/r/Python
https://redd.it/1o8meso
# Weekly Thread: Meta Discussions and Free Talk Friday 🎙️
Welcome to Free Talk Friday on /r/Python! This is the place to discuss the r/Python community (meta discussions), Python news, projects, or anything else Python-related!
## How it Works:
1. Open Mic: Share your thoughts, questions, or anything you'd like related to Python or the community.
2. Community Pulse: Discuss what you feel is working well or what could be improved in the /r/python community.
3. News & Updates: Keep up-to-date with the latest in Python and share any news you find interesting.
## Guidelines:
All topics should be related to Python or the /r/python community.
Be respectful and follow Reddit's Code of Conduct.
## Example Topics:
1. New Python Release: What do you think about the new features in Python 3.11?
2. Community Events: Any Python meetups or webinars coming up?
3. Learning Resources: Found a great Python tutorial? Share it here!
4. Job Market: How has Python impacted your career?
5. Hot Takes: Got a controversial Python opinion? Let's hear it!
6. Community Ideas: Something you'd like to see us do? tell us.
Let's keep the conversation going. Happy discussing! 🌟
/r/Python
https://redd.it/1o8meso
Redditinc
Reddit Rules
Reddit Rules - Reddit
TOML is great, and after diving deep into designing a config format, here's why I think that's true
Developers have strong opinions about configuration formats. YAML advocates appreciate the clean look and minimal syntax. JSON supporters like the explicit structure and universal tooling. INI users value simplicity. Each choice involves tradeoffs, and those tradeoffs matter when you're configuring something that needs to be both human-readable and machine-reliable. This is why I settled on TOML.
https://agent-ci.com/blog/2025/10/15/object-oriented-configuration-why-toml-is-the-only-choice
/r/Python
https://redd.it/1o8ors4
Developers have strong opinions about configuration formats. YAML advocates appreciate the clean look and minimal syntax. JSON supporters like the explicit structure and universal tooling. INI users value simplicity. Each choice involves tradeoffs, and those tradeoffs matter when you're configuring something that needs to be both human-readable and machine-reliable. This is why I settled on TOML.
https://agent-ci.com/blog/2025/10/15/object-oriented-configuration-why-toml-is-the-only-choice
/r/Python
https://redd.it/1o8ors4
Agent CI
Agent CI - Continuous Integration for AI Agents
Git-native evaluation for modern agent development teams. See performance impact before you merge. Track regressions to specific commits.
Can’t get Django emails to send on Render
I’ve been working on a Django project and I’m currently in the final phase (deployment). I’m trying to deploy it for free on Render for demo purposes, but I can’t get emails to send.
I first tried using Gmail with an app password for authentication, but it didn’t work. Then I switched to SendGrid, but the emails still don’t go through.
Has anyone run into this on Render or found a reliable way to get email working for a Django app in a free deployment?
/r/django
https://redd.it/1o8hndt
I’ve been working on a Django project and I’m currently in the final phase (deployment). I’m trying to deploy it for free on Render for demo purposes, but I can’t get emails to send.
I first tried using Gmail with an app password for authentication, but it didn’t work. Then I switched to SendGrid, but the emails still don’t go through.
Has anyone run into this on Render or found a reliable way to get email working for a Django app in a free deployment?
/r/django
https://redd.it/1o8hndt
Reddit
From the django community on Reddit
Explore this post and more from the django community
Made A Video Media Player that Plays Multi-Track Audio with Python
# Crusty Media Player
I made a media player that was built to be able to take Multi-Track Video Files (ex: If you clip Recordings with separate Audio Tracks like System Audio and Microphone Audio) and give you the ability to play them back with both tracks synced without the use of an external editing software like Premiere Pro! And it's Open Source!
# What This Project Does.
It utilizes ffmpeg bundled in to rip apart audio tracks from multi-tracked video media and PyQt6 to build the application and display video media.
GitHub <---- Repo Here
Crusty Media Player v0.1.1 <---- First Downloadable Release Here
# Why Did I Make This?
It's simple really lol. I like clipping funny and cool parts of when my friends and I play video games and such. I also like sometimes editing the videos as a hobby! To make the video editing simpler I have my recording settings set to record two tracks of audio, my system audio, and my microphone audio separate. The problem lies in that, if I ever want to just pull up a clip to show a friend or something, with any other media player I've used I am only able to select one track or the other! I have to open Premiere
/r/Python
https://redd.it/1o8pn4t
# Crusty Media Player
I made a media player that was built to be able to take Multi-Track Video Files (ex: If you clip Recordings with separate Audio Tracks like System Audio and Microphone Audio) and give you the ability to play them back with both tracks synced without the use of an external editing software like Premiere Pro! And it's Open Source!
# What This Project Does.
It utilizes ffmpeg bundled in to rip apart audio tracks from multi-tracked video media and PyQt6 to build the application and display video media.
GitHub <---- Repo Here
Crusty Media Player v0.1.1 <---- First Downloadable Release Here
# Why Did I Make This?
It's simple really lol. I like clipping funny and cool parts of when my friends and I play video games and such. I also like sometimes editing the videos as a hobby! To make the video editing simpler I have my recording settings set to record two tracks of audio, my system audio, and my microphone audio separate. The problem lies in that, if I ever want to just pull up a clip to show a friend or something, with any other media player I've used I am only able to select one track or the other! I have to open Premiere
/r/Python
https://redd.it/1o8pn4t
Python GUIs
PyQt6 Widgets — QCheckBox, QComboBox, QPushButton, QLabel, QSlider
PyQt6 has a huge library of widgets including buttons, checkboxes, list boxes and sliders or dials. Learn how to use them in your apps. In Qt (and most User Interfaces), widget is the name given to a component of the UI that the user can interact with.
Sanguine — Local Semantic Code Search, No Cloud, No APIs
What My Project Does:
Sanguine is a CLI tool that indexes your code across multiple repos and languages using Tree-sitter. It allows you to search for code by meaning, not just keywords. For example:
> sanguine search "parse http headers"
will find the actual functions that perform that task. It integrates with Git (optional post-commit hook) to keep the index up to date. Everything runs locally — no servers, no APIs, no telemetry.
Link:
https://github.com/n1teshy/sanguine
Would love your feedback.
/r/Python
https://redd.it/1o8un9r
What My Project Does:
Sanguine is a CLI tool that indexes your code across multiple repos and languages using Tree-sitter. It allows you to search for code by meaning, not just keywords. For example:
> sanguine search "parse http headers"
will find the actual functions that perform that task. It integrates with Git (optional post-commit hook) to keep the index up to date. Everything runs locally — no servers, no APIs, no telemetry.
Link:
https://github.com/n1teshy/sanguine
Would love your feedback.
/r/Python
https://redd.it/1o8un9r
GitHub
GitHub - n1teshy/sanguine: Fully local code indexing and sematic search tool
Fully local code indexing and sematic search tool - GitHub - n1teshy/sanguine: Fully local code indexing and sematic search tool
Tkinter freezing after successfully executing the code. Have to force quit the kernel and restart everytime on mac m1.
/r/JupyterNotebooks
https://redd.it/1o8rufk
/r/JupyterNotebooks
https://redd.it/1o8rufk
Reddit
From the JupyterNotebooks community on Reddit
Explore this post and more from the JupyterNotebooks community
Turn on Wi-Fi via browser in 7 lines?
What My Project Does
The mininterface project creates dialogs that work everywhere, ex. in the browser.
Here is the app that checks the Wi-Fi status and then turns it on/off. By default, it raises a desktop window with the confirmation dialog. See it here: https://imgur.com/a/20476ZN
#!/usr/bin/env python3
from subprocess import checkoutput, Popen
from mininterface import run
cmd = "nmcli", "radio", "wifi"
state = checkoutput(cmd, text=True).strip() # -> 'enabled' / 'disabled'
m = run() # shows the dialog
if m.confirm(f"The wifi is {state}. Turn it on?"):
Popen(cmd + ("on",))
else:
Popen(cmd + ("off",))#!/usr/bin/env python3
However when you put the
it starts listening on the HTTP port 64646. That way, you can turn on/off the Wi-Fi status (or do anything else, it's up to you to imagine all the possibilities) remotely.
Target Audience
Even though opening a port needs a security
/r/Python
https://redd.it/1o8yhuk
What My Project Does
The mininterface project creates dialogs that work everywhere, ex. in the browser.
Here is the app that checks the Wi-Fi status and then turns it on/off. By default, it raises a desktop window with the confirmation dialog. See it here: https://imgur.com/a/20476ZN
#!/usr/bin/env python3
from subprocess import checkoutput, Popen
from mininterface import run
cmd = "nmcli", "radio", "wifi"
state = checkoutput(cmd, text=True).strip() # -> 'enabled' / 'disabled'
m = run() # shows the dialog
if m.confirm(f"The wifi is {state}. Turn it on?"):
Popen(cmd + ("on",))
else:
Popen(cmd + ("off",))#!/usr/bin/env python3
However when you put the
interface="web" parameter in the run function or when use launch the file with the MININTERFACE_INTERFACE=webenvironment variable set like this:$ MININTERFACE_INTERFACE=web ./wifi.pyit starts listening on the HTTP port 64646. That way, you can turn on/off the Wi-Fi status (or do anything else, it's up to you to imagine all the possibilities) remotely.
Target Audience
Even though opening a port needs a security
/r/Python
https://redd.it/1o8yhuk
GitHub
GitHub - CZ-NIC/mininterface: CLI & dialog toolkit – a minimal interface to Python application (GUI, TUI, CLI + config files, web)
CLI & dialog toolkit – a minimal interface to Python application (GUI, TUI, CLI + config files, web) - CZ-NIC/mininterface
Free-threaded Python on GitHub Actions
https://hugovk.dev/blog/2025/free-threaded-python-on-github-actions/
/r/Python
https://redd.it/1o90fan
https://hugovk.dev/blog/2025/free-threaded-python-on-github-actions/
/r/Python
https://redd.it/1o90fan
Hugo van Kemenade
Free-threaded Python on GitHub Actions
Looking for developers
Hi Django community. I’m looking for a freelance developer or two to help me rewrite the backend of an application I have been building. I have a degree in computer science, but have never worked as a professional developer, let alone a Django developer. I have built my proof of concept in Django, and now I am looking to hire a Django expert to help me rewrite my project. My goal here is to get professional input on my architecture, as well as to hopefully learn some do’s and don’ts about enterprise level Django. There is budget and I intend to pay fair market rate, I’m not asking for any favors, just looking for the right person. Send me a message if you are interested.
/r/django
https://redd.it/1o8c307
Hi Django community. I’m looking for a freelance developer or two to help me rewrite the backend of an application I have been building. I have a degree in computer science, but have never worked as a professional developer, let alone a Django developer. I have built my proof of concept in Django, and now I am looking to hire a Django expert to help me rewrite my project. My goal here is to get professional input on my architecture, as well as to hopefully learn some do’s and don’ts about enterprise level Django. There is budget and I intend to pay fair market rate, I’m not asking for any favors, just looking for the right person. Send me a message if you are interested.
/r/django
https://redd.it/1o8c307
Reddit
From the django community on Reddit
Explore this post and more from the django community
I was tired of writing CREATE TABLE statements for my Pydantic models, so I built PydSQL to automate
Hey,
I'd like to share a project I built to streamline a common task in my workflow. I've structured this post to follow the showcase rules.
What My Project Does:
PydSQL is a lightweight, no dependencies besides Pydantic utility that converts Pydantic models directly into SQL
The goal is to eliminate the manual, error-prone process of keeping SQL schemas synchronized with your Python data models.
For example, you write this Pydantic model:
Python
from pydantic import BaseModel
from datetime import date
class Product(BaseModel):
productid: int
name: str
price: float
launchdate: date
isavailable: bool
And PydSQL instantly generates the corresponding SQL:
SQL
CREATE TABLE product (
productid INTEGER,
name TEXT,
price REAL,
launchdate DATE,
isavailable BOOLEAN
/r/Python
https://redd.it/1o9756d
Hey,
I'd like to share a project I built to streamline a common task in my workflow. I've structured this post to follow the showcase rules.
What My Project Does:
PydSQL is a lightweight, no dependencies besides Pydantic utility that converts Pydantic models directly into SQL
CREATE TABLE statements.The goal is to eliminate the manual, error-prone process of keeping SQL schemas synchronized with your Python data models.
For example, you write this Pydantic model:
Python
from pydantic import BaseModel
from datetime import date
class Product(BaseModel):
productid: int
name: str
price: float
launchdate: date
isavailable: bool
And PydSQL instantly generates the corresponding SQL:
SQL
CREATE TABLE product (
productid INTEGER,
name TEXT,
price REAL,
launchdate DATE,
isavailable BOOLEAN
/r/Python
https://redd.it/1o9756d
Reddit
From the Python community on Reddit: I was tired of writing CREATE TABLE statements for my Pydantic models, so I built PydSQL to…
Explore this post and more from the Python community
If starting from scratch, what would you change in Python. And bringing back an old discussion.
I know that it's a old discussion on the community, the trade of between simplicity and "magic" was a great topic about 10 years ago. Recently I was making a Flask project, using some extensions, and I stop to think about the usage pattern of this library. Like you can create your app in some function scope, and use current_app to retrieve it when inside a app context, like a route. But extensions like socketio you most likely will create a "global" instance, pass the app as parameter, so you can import and use it's decorators etc. I get why in practice you will most likely follow.
What got me thinking was the decisions behind the design to making it this way. Like, flask app you handle in one way, extensions in other, you can create and register multiples apps in the same instance of the extension, one can be retrieved with the proxy like current_app, other don't (again I understand that one will be used only in app context and the other at function definition time). Maybe something like you accessing the instances of the extensions directly from app object, and making something like route declaration,
/r/Python
https://redd.it/1o98n90
I know that it's a old discussion on the community, the trade of between simplicity and "magic" was a great topic about 10 years ago. Recently I was making a Flask project, using some extensions, and I stop to think about the usage pattern of this library. Like you can create your app in some function scope, and use current_app to retrieve it when inside a app context, like a route. But extensions like socketio you most likely will create a "global" instance, pass the app as parameter, so you can import and use it's decorators etc. I get why in practice you will most likely follow.
What got me thinking was the decisions behind the design to making it this way. Like, flask app you handle in one way, extensions in other, you can create and register multiples apps in the same instance of the extension, one can be retrieved with the proxy like current_app, other don't (again I understand that one will be used only in app context and the other at function definition time). Maybe something like you accessing the instances of the extensions directly from app object, and making something like route declaration,
/r/Python
https://redd.it/1o98n90
Reddit
From the Python community on Reddit
Explore this post and more from the Python community
I built a SaaS boilerplate repo in Django that covers everything I would want as a SaaS founder about to build a SaaS!
Thought I'd share with the community my SaaS boilerplate written in Django for the backend and NextJS for the frontend
Tech Stack & Features:
– Frontend: Next.js
– Backend: Django
– Frontend Hosting: Vercel
– Backend Hosting: Render
– Database: PostgreSQL
– Auth: Google Auth
– Payments: Stripe
– Styling: ShadCN + Tailwind CSS
– AI-generated marketing content (OpenAI)
– Social media posting to Reddit & X from dashboard
– Emails via Resend
– Simple custom analytics for landing page metrics
saasboiler.io
/r/django
https://redd.it/1o9b6xw
Thought I'd share with the community my SaaS boilerplate written in Django for the backend and NextJS for the frontend
Tech Stack & Features:
– Frontend: Next.js
– Backend: Django
– Frontend Hosting: Vercel
– Backend Hosting: Render
– Database: PostgreSQL
– Auth: Google Auth
– Payments: Stripe
– Styling: ShadCN + Tailwind CSS
– AI-generated marketing content (OpenAI)
– Social media posting to Reddit & X from dashboard
– Emails via Resend
– Simple custom analytics for landing page metrics
saasboiler.io
/r/django
https://redd.it/1o9b6xw
SaaS Boilerplate
SaaS Boilerplate - Production-Ready Starter Kit
Ship your SaaS 10x faster with our production-ready boilerplate.
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/1o9h81g
# 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/1o9h81g
YouTube
Data Structures and Algorithms in Python - Full Course for Beginners
A beginner-friendly introduction to common data structures (linked lists, stacks, queues, graphs) and algorithms (search, sorting, recursion, dynamic programming) in Python. This course will help you prepare for coding interviews and assessments.
🔗 Course…
🔗 Course…
De-emojifying scripts - setting yourself apart from LLMs
I am wondering if anyone else has had to actively try to set themselves apart from LLMs. That is, to convince others that you made something with blood, sweat and tears rather than clanker oil.
For context, I'm the maintainer of Spectre (https://github.com/jcfitzpatrick12/spectre), a Python program for recording radio spectrograms from software-defined radios. A long while ago, I wrote a setup script - it's the first thing a user runs to install the progam. That script printed text to the terminal indicating progress, and that text included emoji's ✔️
Certainly! Here’s a way to finish your post with a closing sentiment that emphasizes your personal touch and experience:
Markdown
I guess what I'm getting at is, sometimes the little details—like a hand-picked emoji or a carefully-worded progress message—can be a subtle but honest sign that there's a real person behind the code. In a world where so much content is generated, maybe those small human touches are more important than ever.
Has anyone else felt the need to leave these kinds of fingerprints in their work?
/r/Python
https://redd.it/1o9ar5b
I am wondering if anyone else has had to actively try to set themselves apart from LLMs. That is, to convince others that you made something with blood, sweat and tears rather than clanker oil.
For context, I'm the maintainer of Spectre (https://github.com/jcfitzpatrick12/spectre), a Python program for recording radio spectrograms from software-defined radios. A long while ago, I wrote a setup script - it's the first thing a user runs to install the progam. That script printed text to the terminal indicating progress, and that text included emoji's ✔️
Certainly! Here’s a way to finish your post with a closing sentiment that emphasizes your personal touch and experience:
Markdown
I guess what I'm getting at is, sometimes the little details—like a hand-picked emoji or a carefully-worded progress message—can be a subtle but honest sign that there's a real person behind the code. In a world where so much content is generated, maybe those small human touches are more important than ever.
Has anyone else felt the need to leave these kinds of fingerprints in their work?
/r/Python
https://redd.it/1o9ar5b
GitHub
GitHub - jcfitzpatrick12/spectre: A receiver-agnostic program for recording and visualising radio spectrograms.
A receiver-agnostic program for recording and visualising radio spectrograms. - jcfitzpatrick12/spectre
Passing the CSRF Token into a form fetched from Django when the Front-End is in React
This is a reddit post about POSTS not being read. Ironic.
Backstory: A Rollercoaster
What am I posting? A sign-up form. A sign-up from I got from Django.
Good news! As Django is the source of my sign-up form, I can add {% csrf_token %} to the template, and have Django handle the rest.
Bad News: My front end is in React, and not in Django. Therefore, the form POST is handled with Javascript, which views {% csrf_token %} as an error.
Good News! The Django documentation has a page on acquiring the csrf token programmatically in javascript: The Django Documentation has a page on csrf token management.
Bad news: Now what? I'm relying on the form to create the POST request, and not manually creating a fetch() object. Forms don't allow me to neatly edit the POST headers.
Good news: From Googling, I found This Blog Post, which suggests that I could add a hidden <input> tag for sending the csrf token. Even better, I checked the DOM, and voila! I have a idden input element with the csrf token.
Bad News: Doesn't work. Perhaps what I presumed was the CSRF
/r/djangolearning
https://redd.it/1o977gw
This is a reddit post about POSTS not being read. Ironic.
Backstory: A Rollercoaster
What am I posting? A sign-up form. A sign-up from I got from Django.
Good news! As Django is the source of my sign-up form, I can add {% csrf_token %} to the template, and have Django handle the rest.
Bad News: My front end is in React, and not in Django. Therefore, the form POST is handled with Javascript, which views {% csrf_token %} as an error.
Good News! The Django documentation has a page on acquiring the csrf token programmatically in javascript: The Django Documentation has a page on csrf token management.
Bad news: Now what? I'm relying on the form to create the POST request, and not manually creating a fetch() object. Forms don't allow me to neatly edit the POST headers.
Good news: From Googling, I found This Blog Post, which suggests that I could add a hidden <input> tag for sending the csrf token. Even better, I checked the DOM, and voila! I have a idden input element with the csrf token.
Bad News: Doesn't work. Perhaps what I presumed was the CSRF
/r/djangolearning
https://redd.it/1o977gw
Django Project
How to use Django’s CSRF protection | Django documentation
The web framework for perfectionists with deadlines.
2-step Process to Upload a File to Azure Storage Blob without Involving the Back-end to Proxy the Upload: Problems Faced
So there is this 2-step upload process I've implemented to store files in my Django back-end backed by Azure Storage Account blobs:
1. Request an upload SAS URL from back-end: The back-end contacts Azure to get a SAS URL with a UUID name and file extension sent by the user. This is now tracked as a "upload session" by the back-end. The upload session's ID is returned along with the SAS URL to the user.
2. Uploading the File and Registration: The front-end running on the browser uploads the file to Azure directly and once successful, it can register the content. How? It sends the upload session ID returned along with the SAS URL. The back-end uses this ID to retrieve the UUID name of the file, it then verifies that the same file exists in Azure and then finally registers it as a
There are three situations:
1. Upload succeeded and registration successful (desired).
2. Upload failed and registration successful (easily fixable, just block if the upload fails).
3. Upload succeeded but registration failed (problematic).
The problem with the 3rd situation is that the file remains in the Blob Storage but is not registered with the
/r/djangolearning
https://redd.it/1o963yi
So there is this 2-step upload process I've implemented to store files in my Django back-end backed by Azure Storage Account blobs:
1. Request an upload SAS URL from back-end: The back-end contacts Azure to get a SAS URL with a UUID name and file extension sent by the user. This is now tracked as a "upload session" by the back-end. The upload session's ID is returned along with the SAS URL to the user.
2. Uploading the File and Registration: The front-end running on the browser uploads the file to Azure directly and once successful, it can register the content. How? It sends the upload session ID returned along with the SAS URL. The back-end uses this ID to retrieve the UUID name of the file, it then verifies that the same file exists in Azure and then finally registers it as a
Content (a model that represents a file in my back-end).There are three situations:
1. Upload succeeded and registration successful (desired).
2. Upload failed and registration successful (easily fixable, just block if the upload fails).
3. Upload succeeded but registration failed (problematic).
The problem with the 3rd situation is that the file remains in the Blob Storage but is not registered with the
/r/djangolearning
https://redd.it/1o963yi
Reddit
From the djangolearning community on Reddit
Explore this post and more from the djangolearning community
Rant: Python imports are convoluted and easy to get wrong
Inspired by the famous "module 'matplotlib' has no attribute 'pyplot'" error, but let's consider another example: numpy.
This works:
from numpy import ma, ndindex, typing
ma.getmask
ndindex.ndincr
typing.NDArray
But this doesn't:
import numpy
numpy.ma.getmask
numpy.ndindex.ndincr
numpy.typing.NDArray # AttributeError
And this doesn't:
import numpy.ma, numpy.typing
numpy.ma.getmask
numpy.typing.NDArray
import numpy.ndindex # ModuleNotFoundError
And this doesn't either:
from numpy.ma import getmask
from numpy.typing import NDArray
from numpy.ndindex import ndincr # ModuleNotFoundError
There are explanations behind this (
/r/Python
https://redd.it/1o9gyxa
Inspired by the famous "module 'matplotlib' has no attribute 'pyplot'" error, but let's consider another example: numpy.
This works:
from numpy import ma, ndindex, typing
ma.getmask
ndindex.ndincr
typing.NDArray
But this doesn't:
import numpy
numpy.ma.getmask
numpy.ndindex.ndincr
numpy.typing.NDArray # AttributeError
And this doesn't:
import numpy.ma, numpy.typing
numpy.ma.getmask
numpy.typing.NDArray
import numpy.ndindex # ModuleNotFoundError
And this doesn't either:
from numpy.ma import getmask
from numpy.typing import NDArray
from numpy.ndindex import ndincr # ModuleNotFoundError
There are explanations behind this (
numpy.ndindex is not a module, numpy.typing has never been imported so the attribute doesn't exist yet, numpy.ma is a module and has been imported by numpy's __init__.py so everything works), but they don't convince me. I see no reason why import A.B should only work when B is a module. And I see no reason why using a not-yet-imported submodule shouldn't just import it implicitly, clearly you were going to import it anyway. All those subtle inconsistencies where you can't be sure whether something/r/Python
https://redd.it/1o9gyxa
Reddit
From the Python community on Reddit: Rant: Python imports are convoluted and easy to get wrong
Explore this post and more from the Python community