title: How do I use the same render in 2 separate view functions? (django)
body: <p>The project_list() view lists all the projects that already exist and gives you the option to add a new one.
  new_project() handles the creation of that new project then redirects to either the project() view or back to the project_list() including the form so it can display errors.</p>
  
  <p>I keep thinking I should somehow be using the same render function. The reason is that for about a week I didn't realize that after a <code>form.is_valid() == False</code> the page loaded properly but did not list the projects (I had forgotten to include the projects variable in the second render).</p>
  
  <pre><code>@login_required
  def project_list(request):
      projects = request.user.project_set.all()
      return render(request, 'projects/project_list.html', 
                    {'form': ProjectForm(),'projects': projects})
  
  @login_required
  def new_project(request):
      form = ProjectForm()
      if request.method == 'POST':
          form = ProjectForm(data=request.POST)
          if form.is_valid():
              project = form.save(commit=False)  #must specify user before commit
              project.owner = request.user
              project.save()
              return redirect(project)
  
      return render(request, 'projects/project_list.html', 
                    {"form": form, 'projects': request.user.project_set.all()})
  
  
  def project(request, project_id):
      ....
  </code></pre>
  
  <p>How do I keep this logic separate but use the same render call?</p>
  
  <p>Also, hypothetically if I needed to render a third time this one with another additional variable, how should I account for that?</p>