#How to enforce relational constraints between models in Django?

11 messages · Page 1 of 1 (latest)

vague slate
#

Could you just add the FileUrl fields in Sites instead?

carmine yew
vague slate
#

I don't follow. Does that prevent you from adding an upload_id field to Sites?

carmine yew
#

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

main cobalt
#

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

vague slate
#

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_key which 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.
idle prawn
#

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?