How Can I Perform Manytoone Without Foreignkey In Db?
eb_config_object = models.ForeignKey(EbConfig, on_delete=models.CASCADE) I want to serialize an object, which includes another object. But the problem is in my design concept I ca
Solution 1:
eb_config_object = models.ForeignKey(EbConfig, on_delete=models.CASCADE, db_constraint=False)
When I post this question, I had known the attributes(db_constraint) of ForeignKey.But I failed to get through the SQL automatic generated by Django. It tells me can not find a field.
Just migrate your models to physical database by manage.py, and all works.You can get all the benifits from ForeignKey which is given by Django, and there is no any physical ForeignKey in your database.
Post a Comment for "How Can I Perform Manytoone Without Foreignkey In Db?"