It is not that easy as we usually think of.
In fact, it could cause chained impacts on later API usage due to the fact that we have less control on data creation of admin user
Any bad data can potentially cause API calling problem in future usage
So basically, when design ER model for django backend, it is recommended to design with admin UI to detect if there is any required field/logic/relationship which should be required.
Fk, is not that easy as it looks to determine which side to add at first glance.
concept: Required field independent
In admin site, once user creates a new instance, the instance is complete and requires no other dependencies from logic/experiecne anymore.
Course and Student, for example, we set the FK(child) in Course model instead of student. However, logically speaking, a student has to have a course to be meaningful and useful in django, a child without a course could made broken APIs by coding something like course=Course.objects.filter(child=child).
Even if we can handle it by try except block, the serialisers and all other stuff has made this much more complex to handle.
So think of this before design the er model: is this object Required field independent in my design?
And that’s why we recommend to code mode.py and check admin site while designing the ER model
网友评论