Save the same file to multiple db entries in Django
<p>In my Django app the user fills in a form and uploads a file. I need to create multiple db entries, but they all should reference the same file. In other words, if there's 10 objects that need to be created, I don't want to save the uploaded file 10 times to my storage backend. I want to save the file once and then each db entry should reference the same file.</p>

<p>Below is what I currently have, but it creates the file multiple times</p>

<pre><code>class MyModel(models.Model):
    price = models.FloatField()
    my_file = models.FileField()


class BatchTradeForm(forms.Form):
    price = forms.FloatField()
    my_file = forms.FileField()

    def create(self):
        new_items = []
        for x in range(10):
            entry = MyModel(**self.cleaned_data)
            new_items.append(entry)
        MyModel.objects.bulk_create(new_items)

class MyView(FormView):
    def form_valid(self, form):
        form.create()
</code></pre>

<p>I'm guessing I need to save the file manually first to my storage backend and then save the reference some how, but I'm sure there must be a simpler way to achieve this?</p>