Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 15851

Django Use two db in one model

$
0
0

I use RDS. The db have different schemas for Users and Products

class Product(models.Model):    id = models.AutoField(primary_key=True)
class User(models.Model):    id = models.AutoField(primary_key=True)
DATABASES = {"default": {"ENGINE": "django.db.backends.postgresql","OPTIONS": {"options": "-c search_path=public"},"NAME": config("DB_NAME", default=""),"USER": config("DB_USER_NAME", default=""),"PASSWORD": config("DB_PASSWORD", default=""),"HOST": config("DB_HOST", default="db"),"PORT": config("DB_PORT", default=""),    },"data": {"ENGINE": "django.db.backends.postgresql","OPTIONS": {"options": "-c search_path=products"},"NAME": config("DB_NAME", default=""),"USER": config("DB_USER_NAME", default=""),"PASSWORD": config("DB_PASSWORD", default=""),"HOST": config("DB_HOST", default="db"),"PORT": config("DB_PORT", default=""),    },}

Can I create relation between this two tables from different db schemas?Or only one decision move Product table to default db?


Viewing all articles
Browse latest Browse all 15851

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>