In my Django project i have two apps first app(product) and second app(store), product app has a custom user model while store app don't have custom user models. when i try to use a foreign key or one to one relationship between the apps after implementing the code like this for example
from product import models as product_models
class Chart (models.Model):
#Other Fields Here
user = models.ForeignKey(product_models.User, on_delete=models.CASCADE)
and i also tried this method
from product.models import User
class Chart (models.Model):
#Other Fields Here
user = models.ForeignKey(User, on_delete=models.CASCADE)
and also here is how my Database router looks like for allow_relationships
class StoreAppRouter:
route_app_labels = ["product", "store"]
#Other Codes And Functions Here
def allow_relation(self, obj1, obj2, **hints):
if (
obj1._meta.app_label in self.route_app_labels or
obj2._meta.app_label in self.route_app_labels
):
return True
return None
after implementing all this codes when i try to run makemigrations it runs and makemigrations successfully, but when i run ./manage.py migrate specifying the database alias --database=store_db instead of migrating successful it return an mysql error
_mysql.connection.query(self, query)
django.db.utils.OperationalError: (1824, "Failed to open the referenced table 'User'")
can someone please help me out in tackling this issue honestly i have been battling with this for the pass few days it really fustrating.