title: create form from 2 models python django: [Errno 2] No such file or directory
body: <p>I am trying to create a form from 2 models using python and django. 
  Below shows my models:</p>
  
  <pre><code># Create your models here.
  class Action(models.Model):
      name = models.CharField("Action name", max_length=50)
      keywords = models.CharField("Keywords", max_length=50)
      object = models.CharField("Object", max_length=50, blank=True, null=True)
      uploadDate = models.DateField("Date", default=get_current_date)
      UploadedBy = models.CharField("UploadedBy", max_length=50, default="")
  
  class Image(models.Model):
      image = models.FileField(upload_to=get_upload_file_name, default="") 
      action = models.ForeignKey(Action)
  </code></pre>
  
  <p>and the form classes: </p>
  
  <pre><code>class ActionForm(ModelForm):
      #bind form to Action model
      class Meta:
          model = Action
          fields = ['name','keywords', 'object', 'UploadedBy', 'uploadDate']
  
  class ImageForm(ModelForm):
      class Meta:
          model= Image
          fields =['image']
  </code></pre>
  
  <p>The code in views which creates the page from createForm.html template: </p>
  
  <pre><code>def actioncreate(request):
  if request.method == "GET":
      #create the object - Actionform 
      form = ActionForm;
      form2 = ImageForm;
      #pass into it 
      return render(request,'app/createForm.html', { 'form':form, 'form2':form2})
  elif request.method == "POST":
      # take all of the user data entered to create a new action instance in the table
      form = ActionForm(request.POST, request.FILES)
      form2 = ImageForm(request.POST, request.FILES)
      if  form.is_valid() and form2.is_valid():
          #prepare action model  
          act = form.save(commit=False)
          #set the action_id Foreignkey 
          act.action_id = form2.save()
          act.save()
          return HttpResponseRedirect('/actions')
      else:
          form = ActionForm()
          form2 = ImageForm;
          return render(request,'app/createForm.html', { 'form':form, 'form2':form2 })
  </code></pre>
  
  <p>form template:</p>
  
  <pre><code>&lt;form method="post" enctype="multipart/form-data"&gt;
      {% csrf_token %}
      &lt;ul&gt;
      {{ form.as_ul }}
      {{ form2.as_ul }}
      &lt;/ul&gt;
      &lt;button type="submit"&gt;Save&lt;/button&gt;  
      &lt;button name="cancel" onclick="navigate({% url 'home' %})"&gt;Cancel&lt;/button&gt;                
  &lt;/form&gt;
  </code></pre>
  
  <p>The form displays fine when the page is accessed, however once submitted I get this error: </p>
  
  <p>[Errno 2] No such file or directory</p>
  
  <p>and it doesnt seem to like the line: </p>
  
  <pre><code>act.action_id = form2.save()
  </code></pre>
  
  <p>The models created most definiely has all of the fields I am referring to and although I am getting this error the first half (ActionForm) saves into the database, 
  but not the imageForm. Some help would be greatly appreciated! </p>
  
  <p><strong>EDIT</strong> </p>
  
  <p>Error:</p>
  
  <pre><code>OSError at /actions/create
  [Errno 2] No such file or directory
  Request Method: POST
  Request URL:    http://127.0.0.1:8000/actions/create
  Django Version: 1.8.7
  Exception Type: OSError
  Exception Value:    
  [Errno 2] No such file or directory
  Exception Location: C:\Users\Rebecca\Documents\FINALYEAR\CSbackup\MyActionDefiner3 - 2tblWorking - Copy\MyActionDefiner2\env\lib\site-packages\django\core\files\storage.py in _save, line 248
  Python Executable:  C:\Users\Rebecca\Documents\FINALYEAR\CSbackup\MyActionDefiner3 - 2tblWorking - Copy\MyActionDefiner2\env\Scripts\python.exe
  Python Version: 2.7.0
  Python Path:    
  ['C:\\Users\\Rebecca\\Documents\\FINALYEAR\\CSbackup\\MyActionDefiner3 - 2tblWorking - Copy\\MyActionDefiner2',
  'C:\\WINDOWS\\SYSTEM32\\python27.zip',
  'C:\\Users\\Rebecca\\Documents\\FINALYEAR\\CSbackup\\MyActionDefiner3 - 2tblWorking - Copy\\MyActionDefiner2\\env\\DLLs',
  'C:\\Users\\Rebecca\\Documents\\FINALYEAR\\CSbackup\\MyActionDefiner3 - 2tblWorking - Copy\\MyActionDefiner2\\env\\lib',
  'C:\\Users\\Rebecca\\Documents\\FINALYEAR\\CSbackup\\MyActionDefiner3 - 2tblWorking - Copy\\MyActionDefiner2\\env\\lib\\plat-win',
  'C:\\Users\\Rebecca\\Documents\\FINALYEAR\\CSbackup\\MyActionDefiner3 - 2tblWorking - Copy\\MyActionDefiner2\\env\\lib\\lib-tk',
  'C:\\Users\\Rebecca\\Documents\\FINALYEAR\\CSbackup\\MyActionDefiner3 - 2tblWorking - Copy\\MyActionDefiner2\\env\\Scripts',
  'C:\\Python27\\Lib',
  'C:\\Python27\\DLLs',
  'C:\\Python27\\Lib\\lib-tk',
  'C:\\Users\\Rebecca\\Documents\\FINALYEAR\\CSbackup\\MyActionDefiner3 - 2tblWorking - Copy\\MyActionDefiner2\\env',
  'C:\\Users\\Rebecca\\Documents\\FINALYEAR\\CSbackup\\MyActionDefiner3 - 2tblWorking - Copy\\MyActionDefiner2\\env\\lib\\site-packages']
  Server time:    Thu, 28 Jan 2016 15:24:04 +0000
  </code></pre>
  
  <p>Traceback </p>
  
  <pre><code>Request Method: POST
  Request URL: http://127.0.0.1:8000/actions/create
  
  Django Version: 1.8.7
  Python Version: 2.7.0
  Installed Applications:
  ('django.contrib.auth',
  'django.contrib.contenttypes',
  'django.contrib.sessions',
  'django.contrib.sites',
  'django.contrib.messages',
  'django.contrib.staticfiles',
  'app',
  'django.contrib.admin',
  'django.contrib.admindocs')
  Installed Middleware:
  ('django.middleware.common.CommonMiddleware',
  'django.contrib.sessions.middleware.SessionMiddleware',
  'django.middleware.csrf.CsrfViewMiddleware',
  'django.contrib.auth.middleware.AuthenticationMiddleware',
  'django.contrib.messages.middleware.MessageMiddleware')
  
  
  Traceback:
  File "C:\Users\Rebecca\Documents\FINALYEAR\CSbackup\MyActionDefiner3 - 2tblWorking - Copy\MyActionDefiner2\env\lib\site-packages\django\core\handlers\base.py" in get_response
  132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Users\Rebecca\Documents\FINALYEAR\CSbackup\MyActionDefiner3 - 2tblWorking - Copy\MyActionDefiner2\app\views.py" in actioncreate
  53.             act.action_id = form2.save()
  File "C:\Users\Rebecca\Documents\FINALYEAR\CSbackup\MyActionDefiner3 - 2tblWorking - Copy\MyActionDefiner2\env\lib\site-packages\django\forms\models.py" in save
  459.                              construct=False)
  File "C:\Users\Rebecca\Documents\FINALYEAR\CSbackup\MyActionDefiner3 - 2tblWorking - Copy\MyActionDefiner2\env\lib\site-packages\django\forms\models.py" in save_instance
  105.         instance.save()
  File "C:\Users\Rebecca\Documents\FINALYEAR\CSbackup\MyActionDefiner3 - 2tblWorking - Copy\MyActionDefiner2\env\lib\site-packages\django\db\models\base.py" in save
  734.                        force_update=force_update, update_fields=update_fields)
  File "C:\Users\Rebecca\Documents\FINALYEAR\CSbackup\MyActionDefiner3 - 2tblWorking - Copy\MyActionDefiner2\env\lib\site-packages\django\db\models\base.py" in save_base
  762.             updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "C:\Users\Rebecca\Documents\FINALYEAR\CSbackup\MyActionDefiner3 - 2tblWorking - Copy\MyActionDefiner2\env\lib\site-packages\django\db\models\base.py" in _save_table
  846.             result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
  File "C:\Users\Rebecca\Documents\FINALYEAR\CSbackup\MyActionDefiner3 - 2tblWorking - Copy\MyActionDefiner2\env\lib\site-packages\django\db\models\base.py" in _do_insert
  885.                                using=using, raw=raw)
  File "C:\Users\Rebecca\Documents\FINALYEAR\CSbackup\MyActionDefiner3 - 2tblWorking - Copy\MyActionDefiner2\env\lib\site-packages\django\db\models\manager.py" in manager_method
  127.                 return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "C:\Users\Rebecca\Documents\FINALYEAR\CSbackup\MyActionDefiner3 - 2tblWorking - Copy\MyActionDefiner2\env\lib\site-packages\django\db\models\query.py" in _insert
  920.         return query.get_compiler(using=using).execute_sql(return_id)
  File "C:\Users\Rebecca\Documents\FINALYEAR\CSbackup\MyActionDefiner3 - 2tblWorking - Copy\MyActionDefiner2\env\lib\site-packages\django\db\models\sql\compiler.py" in execute_sql
  973.             for sql, params in self.as_sql():
  File "C:\Users\Rebecca\Documents\FINALYEAR\CSbackup\MyActionDefiner3 - 2tblWorking - Copy\MyActionDefiner2\env\lib\site-packages\django\db\models\sql\compiler.py" in as_sql
  931.                 for obj in self.query.objs
  File "C:\Users\Rebecca\Documents\FINALYEAR\CSbackup\MyActionDefiner3 - 2tblWorking - Copy\MyActionDefiner2\env\lib\site-packages\django\db\models\fields\files.py" in pre_save
  314.             file.save(file.name, file, save=False)
  File "C:\Users\Rebecca\Documents\FINALYEAR\CSbackup\MyActionDefiner3 - 2tblWorking - Copy\MyActionDefiner2\env\lib\site-packages\django\db\models\fields\files.py" in save
  93.             self.name = self.storage.save(name, content, max_length=self.field.max_length)
  File "C:\Users\Rebecca\Documents\FINALYEAR\CSbackup\MyActionDefiner3 - 2tblWorking - Copy\MyActionDefiner2\env\lib\site-packages\django\core\files\storage.py" in save
  63.         name = self._save(name, content)
  File "C:\Users\Rebecca\Documents\FINALYEAR\CSbackup\MyActionDefiner3 - 2tblWorking - Copy\MyActionDefiner2\env\lib\site-packages\django\core\files\storage.py" in _save
  248.                     fd = os.open(full_path, flags, 0o666)
  
  Exception Type: OSError at /actions/create
  Exception Value: [Errno 2] No such file or directory
  </code></pre>