title: How do I upload pickled data to django FileField?
body: <p>I would like to store large dataset generated in Python in a Django model. My idea was to pickle the data to a string and upload it to FileField of my model. My django model is:</p>
  
  <pre><code>#models.py
  from django.db import models
  
  class Data(models.Model):
      label = models.CharField(max_length=30)
      file = models.FileField(upload_to="data")
  </code></pre>
  
  <p>In my Python program I would like to do the following:</p>
  
  <pre><code>import random, pickle
  
  data_entry = Data(label="somedata")
  somedata = [random.random() for i in range(10000)]
  # Next line does NOT work 
  #data_entry.file.save(filename, pickle.dumps(somedata))
  </code></pre>
  
  <p>How should I modify the last line to store <code>somedata</code> in <code>file</code> preserving the paths defined with <code>upload_to</code> parameter?</p>