-
Notifications
You must be signed in to change notification settings - Fork 17
How Torrent Models Work
Basically, the system works like this:
In the most basic sense, you need to worry about:
- Upload Groups (
UploadGroupsubclasses) - Uploads (
Uploadsubclasses)
On both of these (i.e. on your own subclasses of UploadGroup and Upload), you can attach your own metadata, just like in a normal model.
However, in some cases, you might need to stick more grouping in to your torrents.
For example, in the music app, we have the following models:
-
MusicUpload(Uploadsubclass) -
Master(UploadGroupsubclass)
But, we also have:
-
Release(DescendingModelsubclass)
This is because each Master may have multiple Releases - think along the lines of if you have a single album (a Master) which has an original version (an Release) and a Japan-only version with extra tracks (a different Release).
Each MusicUpload represents one particular encoding of one particular Release, which belongs to a Master.
Note, however, if you do this, you need to make two additional changes to your models:
- On your
UploadGroupsubclass, you must overrideget_child_modelto return the class you're inserting - On the class you're inserting, you must define a
parentForeignKeypointing at the parent class (or use aGenericForeignKey) - On the class you're inserting, you must also override
get_child_modelto return theUploadsubclass beneath it
These steps help to establish a hierarchy of models that can be traversed up and down.
Here's my helpful diagram:
