title: Django: Can't pass parameters to Python class, name 'uid' is not defined
body: <p>I have been struggling with what seems to be a simple problem for quite a while.</p>
  
  <p>I have little experience programming in Python, so I apologize for this. I have done my best to try every solution, and check this site for help.. to little avail.</p>
  
  <p>I am trying to write a simple class to help me upload pairs of user-submitted files. I've wanted it to do something like this:</p>
  
  <ul>
  <li>Upload files <em>something</em>.txt and <em>somethingelse</em>.txt</li>
  <li>Process files</li>
  <li>Rename files to <strong><em>uniqueID</strong>-1</em>.txt and <strong><em>uniqueID</strong>-2</em>.txt</li>
  <li>Save files on remote server</li>
  </ul>
  
  <hr>
  
  <p>So here is how I'm currently doing it for one file (since I'm doing a pair, this process can just be repeated a second time)</p>
  
  <p>I currently take information from a POST request to do the following in my views.py (where newID is the uniqueID, num is the suffix of the filename):</p>
  
  <pre><code>newID = uuid4().hex
  num = 1
  upload = UploadFile()
  upload.file = request.FILES['inputfile1'])
  upload.save()
  </code></pre>
  
  <p>The UploadFile class is in my models.py as such:</p>
  
  <pre><code>class UploadFile(models.Model):
      file = models.FileField(upload_to=path_and_rename('path/', str(uid) + "_" + str(num)))
  </code></pre>
  
  <p>(where path_and_rename is a function to set the path and name of file respectively)</p>
  
  <hr>
  
  <p>As you may notice, I never pass the newID and num to my UploadFile class. That's where I've been having trouble. I am not very familiar with Python/Django, and I have spent awhile trying to brush up. I still can't quite figure it out. I know this is a very simple problem!</p>
  
  <p>As written, I get the error on execution: <strong>name 'uid' is not defined</strong></p>
  
  <p>I have tried creating a constructor to initialize newID and num with __init__, but I still get a similar problem. I have also tried setting the field as I did with "upload.file = ...", but that didn't work either. I've tried moving the "file" field into functions and constructors as well. </p>
  
  <p>I can't really find a balance where I'm able to keep "file" in the body of class, and still have access to "self" or any fields.</p>
  
  <p>How do I pass these integers into my UploadFile class?</p>
  
  <p>Thank you very much for your time and help. I hope I explained my dilemma sufficiently, and I hope to figure this out soon!</p>