#How to enforce relational constraints between models in Django?
11 messages · Page 1 of 1 (latest)
Sites model exists because admin can add/ remove sites what they want
I don't follow. Does that prevent you from adding an upload_id field to Sites?
if i add upload_id to sites then how the admin will add new sites?
fileurl models for user where user can upload a particular file to multiple sites then each site's file id store in upload_id
I'll instead ask what is the purpose of FileUrl model here
At glance it looks to me it should be merged with another model
especially when it's o2o with sites and there is an existing relationship
I am struggling to understand, sorry. Maybe you can try explain in plain language instead of Django or Database concepts.
Here's what I understand so far:
- A Site can have multiple Files.
- A File may belong to multiple Sites.
- A Site can have an
api_keywhich must belong to a User. - A User can have many SiteApis and Sites.
- A Site can have one FileUrl.
- A File can have many FileUrls.
Have the fileurl hav a fk to both sites and file? To make it easy, make a m2m between files and sites, and make siteurl the m2m through model?