Hi guys
I am very new to python and django. I am going through the tutorial on their website, which as been pretty good so far and all is very easy to understand. I am just struggling with something. I need my api to handle file uploads. I have my model setup like this:
models.py:
class Document(models.Model):
fileData = models.FileField(upload_to='documents/%Y/%m/%d')
created = models.DateTimeField(auto_now_add=True)
views.py:
class DocumentList(generics.ListCreateAPIView):
"""List all documents on server and create new"""
queryset = Document.objects.all()
serializer_class = DocumentSerializer
permission_classes = (permissions.IsAuthenticated,)
Now all the file upload and listing stuff is working perfectly. But now I want add columns for the file meta data. For eg. Filesize, original filename, etc. Creating the columns in the model and database is easy, that is no problem.
My question is, where do I put code to actually get this data from the file? I cannot seem to find anything online around this. Does it go in my serializer class? Any help or examples will be much appreciated.
Thanks