Reputation: 1
I am writing an application in Django Rest Framework that accepts employee data and generates a barcode for him in pdf format. then I have to give these files on request. question: how should i store the files created in the application? I have a model of the employee itself and I have a second model with a one-to-one relationship with the employee model and a field for the file. what type of field to use: FileField or FilePathField? the generated files will be stored on the server. they will have to be given through the API in the form of binary data
Upvotes: 0
Views: 447
Reputation: 334
It depends :) You can store file directly into the database, or in the filesystem.
In db, you could use a BinaryField, but, most of the time, its a bad choice.
In the filesystem, you effectively have this two choices :
If you don't like to reinvent the wheel, you should definitively use a FileField.
Upvotes: 1