0

Currently I am working on project in which I need to calculate all the payment methods of complete event by using django model's field, I have to calculate the data and convert it into file which I need to upload into another table. My project is configured by Amazon S3. I need to show the file path in API, so my file will be stored in my model and when I hit API my updated report's path come as Response

I see many solutions, but still can't fulfill my requirement.

for example:

My Model:

  class foo(models.Model):
       ....
       ....

another model in which I want to save:

  class Report(models.Model):
     report =models.FileField(..)

My API:

 class fooAPIView(ListCreateApiView):
    foo_queryset = foo.objects.all()
    report = Report.objects.create(report= foo_queryset)
    return Response(report.url)

Whats the best practice and way to create the file and saved in django models

  • Please check if this helps any [Exporting items from a model to CSV Django](https://stackoverflow.com/questions/15029666/exporting-items-from-a-model-to-csv-django-python/15029693). – Rfroes87 Sep 10 '20 at 13:52
  • Thank you very much for share it and this will help me to create a file but I want to store that file in another model, Kindly help if you have idea about it too – Mahad_Akbar Sep 17 '20 at 12:52

0 Answers0