title: Getting file uploads to work with Django & Cloudinary
body: <p>I am trying to use Cloudinary as a CDN and am having some trouble getting file uploads to work properly. I have followed their blog posts and website, but am running into a consistent and very annoying error.</p>
  
  <p>I have a model associated with both an image (a cover photo) and a media object (a PDF or ebook, like a .mobi or .epub). I have a model form set up to create an object:</p>
  
  <pre><code>class NewMediaObjectForm(forms.ModelForm):
  
      class Meta:
          model = MediaObject
          fields = ('cover_photo', ...)
          cover_photo = CloudinaryJsFileField(options={'tags': 'cover_photo'})
  </code></pre>
  
  <p>Now, I've read <a href="http://cloudinary.com/documentation/django_image_upload" rel="nofollow">this tutorial from Cloudinary</a> and I know that their form looks like this:</p>
  
  <pre><code>class NewMediaObjectForm(forms.ModelForm):
  
      class Meta:
          model = MediaObject
          fields = ('cover_photo', ...)
      cover_photo = CloudinaryJsFileField(options={'tags': 'cover_photo'})
  </code></pre>
  
  <p>Here's my problem: if I match their level of indention, the generated HTML shows that the input field is getting all of the right Cloudinary stuff attached to it - but the upload itself doesn't work. The page simply refreshes with an error message stating that no image was selected. Importantly, I can see from the generated HTML that the tags I've specified are coming through.</p>
  
  <p>If I use method #1, with my indention, the file uploads to Cloudinary but none of my tags are applied. It also treats everything as an image, giving me a "invalid image file" error when trying to upload anything other than images (such as the ebook files I mentioned earlier). </p>
  
  <p>I want both - how can I get this upload field to work AND get it to respect the options I'm trying to define?</p>
  
  <p>(I do have cloudinary.config called in the appropriate views; I do have cloudinary_includes and cloudinary_js_config in the appropriate templates; I've imported everything and am calling cl_init_js_callbacks on the form in the view.)</p>
  
  <p>One more addition - I am running this on a local machine using manage.py's runserver rather than deploying, if that has any impact on the configuration. </p>
  
  <p>UPDATE:
  I found something I was doing wrong. I've fixed it and made things worse. </p>
  
  <p>The necessary jQuery was not being loaded. Now I <em>am</em> loading it, but the upload button simply doesn't function. I press the button, I select the file, the select dialog disappears, and it shows that no file has been selected. However, I can see that the tags are being passed to the generated HTML, so it's a step in the right direction. Any ideas?</p>