So I have worked in django 2.2 where I have multiple apps that I use the same models.py file in for all of them (same meaning I make sure each one is exactly the same as the others not one single models.py). When I do migrations I have no problem with anything. When I started using django 3.1 if I try to do the same it creates tables in the postgres database for each app. For example I have a table called Menu_Item it creates tables for home_Menu_Item, custOrders_Menu_Item, and menu_Menu_Item. How to get them all to use the same postgres table Menu_Item. Why is django 3 acting differently. I'm not sure what changed but it isn't working out well for me.
menu/models.py
from django.db import models
# Create your models here.
class Menu_Item(models.Model):
class MenuTypes(models.TextChoices):
APPETIZER = "Appetizer"
ENTREE = "Entree"
DESSERT = "Dessert"
WINE = "Wine"
BEER = "Beer"
COCKTAIL = "Cocktail"
name = models.CharField(max_length = 50)
description = models.CharField(max_length = 250)
price = models.DecimalField(max_digits = 4, decimal_places= 2)
item_type = models.CharField(max_length = 10, choices=MenuTypes.choices, default=MenuTypes.APPETIZER)
def __str__(self):
class Menu_Drink_Item(models.Model):
class DrinkChoices(models.TextChoices):
WINE = "Wine"
BEER = "Beer"
COCKTAIL = "Cocktail"
name = models.CharField(max_length = 50)
description = models.CharField(max_length = 250)
price = models.DecimalField(max_digits = 4, decimal_places= 2)
drink_type = models.CharField(max_length = 10, choices=DrinkChoices.choices, default=DrinkChoices.COCKTAIL)
pairing_options = models.ForeignKey(Menu_Item, null=True, blank=True, on_delete = models.SET_NULL)
def __str__(self):
custOrders/models.py
from django.db import models
from menu.models import Menu_Item
# Create your models here.
class tableTable(models.Model):
tableTypeChoices = [
('bar', 'bar'),
('booth', 'booth'),
('table', 'table'),
('hi-top', 'hi-top'),
('patio', 'patio'),
]
statusChoices = [
('cleaned', 'cleaned'),
('seated', 'seated'),
('closed', 'closed'),
('reserved', 'reserved'),
]
#primary key field
seats = models.IntegerField(blank=False, null=False)
tableType = models.CharField(max_length=255, blank=False, null=False, choices=tableTypeChoices)
status = models.CharField(max_length=255, blank=False, null=False, choices=statusChoices)
server = models.CharField(max_length=255, blank=False, null=False)
def __str__(self):
return '%s %s' % (
self.id, self.tableType)
class Menu_Item(models.Model):
class MenuTypes(models.TextChoices):
APPETIZER = "Appetizer"
ENTREE = "Entree"
DESSERT = "Dessert"
WINE = "Wine"
BEER = "Beer"
COCKTAIL = "Cocktail"
name = models.CharField(max_length = 50)
description = models.CharField(max_length = 250)
price = models.DecimalField(max_digits = 4, decimal_places= 2)
item_type = models.CharField(max_length = 10, choices=MenuTypes.choices, default=MenuTypes.APPETIZER)
def __str__(self):
Any ideas?