Flask + PostgreSQL + Flask-Migrate works locally but not on Render (no tables created)
I'm deploying a Flask app to Render using PostgreSQL and Flask-Migrate. Everything works fine on localhost — tables get created, data stores properly, no issues at all.
But after deploying to Render:
* The app runs, but any DB-related operation causes a 500 Internal Server Error.
* I’ve added the `DATABASE_URL` in Render environment .
* My app uses Flask-Migrate. I’ve run `flask db init`, m`igrate`, and `upgrade` locally.
* On Render, I don’t see any tables created in the database (even after deployment).
* How to solve this ? Can anybody give full steps i asked claude , gpt ,grok etc but no use i am missing out something.
/r/flask
https://redd.it/1md6i0f
I'm deploying a Flask app to Render using PostgreSQL and Flask-Migrate. Everything works fine on localhost — tables get created, data stores properly, no issues at all.
But after deploying to Render:
* The app runs, but any DB-related operation causes a 500 Internal Server Error.
* I’ve added the `DATABASE_URL` in Render environment .
* My app uses Flask-Migrate. I’ve run `flask db init`, m`igrate`, and `upgrade` locally.
* On Render, I don’t see any tables created in the database (even after deployment).
* How to solve this ? Can anybody give full steps i asked claude , gpt ,grok etc but no use i am missing out something.
/r/flask
https://redd.it/1md6i0f
Reddit
From the flask community on Reddit
Explore this post and more from the flask community
Forget metaclasses; Python’s
Think you need a metaclass? You probably just need
Most people reach for metaclasses when customizing subclass behaviour. But in many cases,
What is
It’s a hook that gets automatically called on the base class whenever a new subclass is defined. Think of it like a class-level
# Why use it?
Validate or register subclasses
Enforce class-level interfaces or attributes
Automatically inject or modify subclass properties
Avoid the complexity of full metaclasses
# Example: Plugin Auto-Registration
class PluginBase:
plugins =
def initsubclass(cls, **kwargs):
super().initsubclass(kwargs)
print(f"Registering: {cls.name}")
PluginBase.plugins.append(cls)
class PluginA(PluginBase): pass
class PluginB(PluginBase): pass
print(PluginBase.plugins)
Output:
Registering: PluginA
Registering: PluginB
/r/Python
https://redd.it/1mevs3i
__init_subclass__ is all you really needThink you need a metaclass? You probably just need
__init_subclass__; Python’s underused subclass hook.Most people reach for metaclasses when customizing subclass behaviour. But in many cases,
__init_subclass__ is exactly what you need; and it’s been built into Python since 3.6.What is
__init_subclass__**?**It’s a hook that gets automatically called on the base class whenever a new subclass is defined. Think of it like a class-level
__init__, but for subclassing; not instancing.# Why use it?
Validate or register subclasses
Enforce class-level interfaces or attributes
Automatically inject or modify subclass properties
Avoid the complexity of full metaclasses
# Example: Plugin Auto-Registration
class PluginBase:
plugins =
def initsubclass(cls, **kwargs):
super().initsubclass(kwargs)
print(f"Registering: {cls.name}")
PluginBase.plugins.append(cls)
class PluginA(PluginBase): pass
class PluginB(PluginBase): pass
print(PluginBase.plugins)
Output:
Registering: PluginA
Registering: PluginB
/r/Python
https://redd.it/1mevs3i
Reddit
From the Python community on Reddit
Explore this post and more from the Python community
AFDebugging help: Flaskapp can't find static files
I'm running flask 3.0.3 with python 3.11 and have a strange issue where it can't find a simple css file I have in there. When I give a path to my static file I get a 404 can't be found.
my file structure is like the below:
project
init.py
controller.py
config.py
templates
templatefile.html
static
style.css
I haven't tried a lot yet, I started seeing if I made a mistake compared to how it's done in the flask tutorial but I can't see where I've gone wrong, I also looked on stack overflow a bit. I've tried setting a path directly to the static folder, inside __init__.py
Is there a way I can debug this and find what path it is looking for static files in?
# Edit: Additional info from questions in comments.
- I am using
/r/flask
https://redd.it/1mmptbh
I'm running flask 3.0.3 with python 3.11 and have a strange issue where it can't find a simple css file I have in there. When I give a path to my static file I get a 404 can't be found.
my file structure is like the below:
project
init.py
controller.py
config.py
templates
templatefile.html
static
style.css
I haven't tried a lot yet, I started seeing if I made a mistake compared to how it's done in the flask tutorial but I can't see where I've gone wrong, I also looked on stack overflow a bit. I've tried setting a path directly to the static folder, inside __init__.py
app = Flask(__name__, static_folder=STATIC_DIR)Is there a way I can debug this and find what path it is looking for static files in?
# Edit: Additional info from questions in comments.
- I am using
/r/flask
https://redd.it/1mmptbh
DataCompose: Bringing shadcn's copy-to-own pattern to data engineering
# What My Project Does
DataCompose provides 100+ battle-tested PySpark primitives for cleaning contact data (addresses, emails, phones). Instead of importing a library, you copy the source code directly into your project (like Shadcn). Think of it as production-ready snippets that you own and can modify.
## Target Audience
- **Data Engineers** working in restricted environments (banks, healthcare, government)
- **Teams** tired of writing the same address/email/phone cleaning logic at every job
- **Anyone** who needs to customize data cleaning for their specific edge cases
- **Spark users** who want composable transformations without external dependencies
## Comparisons
- **vs pandas/polars**: Built specifically for PySpark at scale, not local dataframes
- **vs Great Expectations**: We clean data, and have validation functions
- **vs dbt**: We handle the messy cleaning before your dbt transformations
- **vs custom UDFs**: Pre-tested, composable, and includes 336 tests
This is the architecture that I went with, there is (supposed) a registry that lives where the datacompose cli copies and pastes the primitive (the data cleaner that you want) to your repo, and you can fully edit the code, and extend anyway you want. And then you can delete the cli and the code still works.
## Code Example
```bash
datacompose init
# Generate email cleaning primitives
datacompose add clean_emails --target
/r/Python
https://redd.it/1mq0v3w
# What My Project Does
DataCompose provides 100+ battle-tested PySpark primitives for cleaning contact data (addresses, emails, phones). Instead of importing a library, you copy the source code directly into your project (like Shadcn). Think of it as production-ready snippets that you own and can modify.
## Target Audience
- **Data Engineers** working in restricted environments (banks, healthcare, government)
- **Teams** tired of writing the same address/email/phone cleaning logic at every job
- **Anyone** who needs to customize data cleaning for their specific edge cases
- **Spark users** who want composable transformations without external dependencies
## Comparisons
- **vs pandas/polars**: Built specifically for PySpark at scale, not local dataframes
- **vs Great Expectations**: We clean data, and have validation functions
- **vs dbt**: We handle the messy cleaning before your dbt transformations
- **vs custom UDFs**: Pre-tested, composable, and includes 336 tests
This is the architecture that I went with, there is (supposed) a registry that lives where the datacompose cli copies and pastes the primitive (the data cleaner that you want) to your repo, and you can fully edit the code, and extend anyway you want. And then you can delete the cli and the code still works.
## Code Example
```bash
datacompose init
# Generate email cleaning primitives
datacompose add clean_emails --target
/r/Python
https://redd.it/1mq0v3w
Reddit
From the Python community on Reddit: DataCompose: Bringing shadcn's copy-to-own pattern to data engineering
Explore this post and more from the Python community
React + Django Channels Help (groupadd() and groupsend() not working)
Hi,
I am learning how to write a project using Django REST Framework + Django Channels + React for the first time and noticed that I for some reason methods like .groupadd() and .groupsend() do not seem to be working in my project, preventing me from joining the Django Channels room and sending messages between the room's members, respectively.
I have tried using ChatGPT to help me debug the problem but it keeps sending me around in circles by asking me to change the "type" field from "chat.join" to "chatjoin" (the name of my async def chatjoin() method), putting print statements before and behind groupadd() and groupsend() to see if those statements appear in the terminal and thus if execution has stopped during the execution of groupadd()/groupsend(), as well as wrapping the chatjoin() method's implementation in try-catch statements to see if it is silently failing, verifying if my Redis database is up and running at the right address (it is), and even overriding the init() and dispatch methods of the my Consumer class to verify if the "chatjoin" method is being received by my consumer (it is).
None of these have worked and it seems like my entire Consumer class is working (I
/r/djangolearning
https://redd.it/1mk8i2j
Hi,
I am learning how to write a project using Django REST Framework + Django Channels + React for the first time and noticed that I for some reason methods like .groupadd() and .groupsend() do not seem to be working in my project, preventing me from joining the Django Channels room and sending messages between the room's members, respectively.
I have tried using ChatGPT to help me debug the problem but it keeps sending me around in circles by asking me to change the "type" field from "chat.join" to "chatjoin" (the name of my async def chatjoin() method), putting print statements before and behind groupadd() and groupsend() to see if those statements appear in the terminal and thus if execution has stopped during the execution of groupadd()/groupsend(), as well as wrapping the chatjoin() method's implementation in try-catch statements to see if it is silently failing, verifying if my Redis database is up and running at the right address (it is), and even overriding the init() and dispatch methods of the my Consumer class to verify if the "chatjoin" method is being received by my consumer (it is).
None of these have worked and it seems like my entire Consumer class is working (I
/r/djangolearning
https://redd.it/1mk8i2j
Reddit
From the djangolearning community on Reddit
Explore this post and more from the djangolearning community
Swizzle: flexible multi-attribute access in Python
Ever wished you could just do `obj.yxz` and grab all three at once? I got a bit obsessed playing around with `__getattr__` and `__setattr__`, and somehow it turned into a tiny library.
# What my Project Does
Swizzle lets you grab or assign multiple attributes at once, and it works with regular classes, dataclasses, Enums, etc. By default, swizzled attributes return a `swizzledtuple` (like an enhanced `namedtuple`) that keeps the original class name and allows continuous swizzling.
import swizzle
# Example with custom separator
@swizzle(sep='_', setter=True)
class Person:
def __init__(self, name, age, city, country):
self.name = name
self.age = age
self.city = city
self.country = country
p = Person("Jane", 30, "Berlin", "Germany")
# Get multiple attributes with separator
/r/Python
https://redd.it/1muhw70
Ever wished you could just do `obj.yxz` and grab all three at once? I got a bit obsessed playing around with `__getattr__` and `__setattr__`, and somehow it turned into a tiny library.
# What my Project Does
Swizzle lets you grab or assign multiple attributes at once, and it works with regular classes, dataclasses, Enums, etc. By default, swizzled attributes return a `swizzledtuple` (like an enhanced `namedtuple`) that keeps the original class name and allows continuous swizzling.
import swizzle
# Example with custom separator
@swizzle(sep='_', setter=True)
class Person:
def __init__(self, name, age, city, country):
self.name = name
self.age = age
self.city = city
self.country = country
p = Person("Jane", 30, "Berlin", "Germany")
# Get multiple attributes with separator
/r/Python
https://redd.it/1muhw70
Reddit
From the Python community on Reddit: Swizzle: flexible multi-attribute access in Python
Explore this post and more from the Python community
I created a 5 hour free tutorial on creating your own git from scratch using Python
Ever wondered what happens when you run git init, git add, or git commit? In this 5 hour tutorial, we’ll build a minimal version of Git from scratch in Python. By the end, you’ll understand the internals - objects, commits, branches and more because you’ll have written them yourself!
Watch the video here - https://www.youtube.com/watch?v=g2cfjDENSyw
/r/Python
https://redd.it/1myvz9i
Ever wondered what happens when you run git init, git add, or git commit? In this 5 hour tutorial, we’ll build a minimal version of Git from scratch in Python. By the end, you’ll understand the internals - objects, commits, branches and more because you’ll have written them yourself!
Watch the video here - https://www.youtube.com/watch?v=g2cfjDENSyw
/r/Python
https://redd.it/1myvz9i
YouTube
I Built My Own Git From Scratch (And Here's How You Can) | Git Tutorial
In this 5 hour tutorial, we will build our own Git from scratch using Python! We will understand how operations like init, add, commit, branch, checkout, status and log is implemented in git (by building it ourselves).
Source code - https://github.com/…
Source code - https://github.com/…
How To Implement A Recursive Formset/Form
Hello! New Django dev here. How would one implement a recursive formset?
For example, I want to nest `FormsetA` inside another instance of `FormsetA` as a formset.
I tried adding it dynamically within the `__init__` such that there is a base condition (i.e., `if self.depth >= self.max_depth: return`), but it still goes on and on. Is there a sample online I could use as reference to make this work?
Any help is much appreciated!
/r/django
https://redd.it/1n6cw9x
Hello! New Django dev here. How would one implement a recursive formset?
For example, I want to nest `FormsetA` inside another instance of `FormsetA` as a formset.
I tried adding it dynamically within the `__init__` such that there is a base condition (i.e., `if self.depth >= self.max_depth: return`), but it still goes on and on. Is there a sample online I could use as reference to make this work?
Any help is much appreciated!
/r/django
https://redd.it/1n6cw9x
Reddit
From the django community on Reddit
Explore this post and more from the django community
Gmail SMTP on Railway suddenly failing with Errno 101 Network is unreachable + site slowdown when sending emails
Hey all,
I’ve had a Django app running on Railway for \~5 months without email issues. I’m using Gmail Workspace SMTP with
Symptoms:
Email sends started failing out of nowhere.
Any request that sends mail hangs and degrades performance.
Sometimes seeing worker timeouts.
Swapping to Resend works, but I prefer Gmail Workspace so messages appear in our “Sent” mailbox.
Error (logs):
Traceback (most recent call last):
File "/app/users/emails.py", line 143, in sendinternalconfirmation
msg.send()
File "/opt/venv/lib/python3.13/site-packages/django/core/mail/message.py", line 301, in send
return self.getconnection(failsilently).sendmessages([self])
File "/opt/venv/lib/python3.13/site-packages/django/core/mail/backends/smtp.py", line 128, in sendmessages
newconncreated = self.open()
File "/opt/venv/lib/python3.13/site-packages/django/core/mail/backends/smtp.py", line 86, in open
self.connection = self.connectionclass(self.host, self.port, **connectionparams)
File "/root/.nix-profile/lib/python3.13/smtplib.py", line 255, in init
(code, msg) = self.connect(host, port)
/r/django
https://redd.it/1n7ozeo
Hey all,
I’ve had a Django app running on Railway for \~5 months without email issues. I’m using Gmail Workspace SMTP with
django.core.mail.backends.smtp.EmailBackend and an app password. A few days ago, outgoing emails started failing and any view that triggers an email slows the site to a crawl.Symptoms:
Email sends started failing out of nowhere.
Any request that sends mail hangs and degrades performance.
Sometimes seeing worker timeouts.
Swapping to Resend works, but I prefer Gmail Workspace so messages appear in our “Sent” mailbox.
Error (logs):
Traceback (most recent call last):
File "/app/users/emails.py", line 143, in sendinternalconfirmation
msg.send()
File "/opt/venv/lib/python3.13/site-packages/django/core/mail/message.py", line 301, in send
return self.getconnection(failsilently).sendmessages([self])
File "/opt/venv/lib/python3.13/site-packages/django/core/mail/backends/smtp.py", line 128, in sendmessages
newconncreated = self.open()
File "/opt/venv/lib/python3.13/site-packages/django/core/mail/backends/smtp.py", line 86, in open
self.connection = self.connectionclass(self.host, self.port, **connectionparams)
File "/root/.nix-profile/lib/python3.13/smtplib.py", line 255, in init
(code, msg) = self.connect(host, port)
/r/django
https://redd.it/1n7ozeo
Reddit
From the django community on Reddit
Explore this post and more from the django community
I built a Python library to simplify complex SQLAlchemy queries with a clean architecture.
Hey r/Python,
Like many of you, I've spent countless hours writing boilerplate code for web APIs that use SQLAlchemy. Handling dynamic query parameters for filtering on nested relationships, sorting, full-text search, and pagination always felt repetitive and prone to errors.
To solve this, I created fastapi-query-builder.
Don't let the name fool you! While it was born from a FastAPI project, it's fundamentally a powerful, structured way to handle SQLAlchemy queries that can be adapted to any Python framework (Flask, Django Ninja, etc.).
The most unique part is its installation, inspired by shadcn/ui. Instead of being just another black-box package, you run query-builder init, and it copies the entire source code into your project. This gives you full ownership to customize, extend, or fix anything you need.
GitHub Repo: **https://github.com/Pedroffda/fastapi-query-builder**
# How it Works: A Clean Architecture
The library encourages a clean, three-layer architecture to separate concerns:
1. BaseService: The data access layer. It talks to the database using SQLAlchemy and the core QueryBuilder. It only deals with SQLAlchemy models.
2. BaseMapper: The presentation layer. It's responsible for transforming SQLAlchemy models into Pydantic schemas, intelligently handling relationship loading and field selection (select_fields).
3. BaseUseCase: The business logic layer. It coordinates the service and the mapper. Your API endpoint talks to this layer, keeping your routes incredibly clean.
# A Quick,
/r/Python
https://redd.it/1n8b41e
Hey r/Python,
Like many of you, I've spent countless hours writing boilerplate code for web APIs that use SQLAlchemy. Handling dynamic query parameters for filtering on nested relationships, sorting, full-text search, and pagination always felt repetitive and prone to errors.
To solve this, I created fastapi-query-builder.
Don't let the name fool you! While it was born from a FastAPI project, it's fundamentally a powerful, structured way to handle SQLAlchemy queries that can be adapted to any Python framework (Flask, Django Ninja, etc.).
The most unique part is its installation, inspired by shadcn/ui. Instead of being just another black-box package, you run query-builder init, and it copies the entire source code into your project. This gives you full ownership to customize, extend, or fix anything you need.
GitHub Repo: **https://github.com/Pedroffda/fastapi-query-builder**
# How it Works: A Clean Architecture
The library encourages a clean, three-layer architecture to separate concerns:
1. BaseService: The data access layer. It talks to the database using SQLAlchemy and the core QueryBuilder. It only deals with SQLAlchemy models.
2. BaseMapper: The presentation layer. It's responsible for transforming SQLAlchemy models into Pydantic schemas, intelligently handling relationship loading and field selection (select_fields).
3. BaseUseCase: The business logic layer. It coordinates the service and the mapper. Your API endpoint talks to this layer, keeping your routes incredibly clean.
# A Quick,
/r/Python
https://redd.it/1n8b41e