title: How to redirect to a dynamic url in django
body: <p>I am working on a django project. in the project I have a dynamic url as follows</p>
  <pre><code>app_name = 'test'
  
  urlpatterns = [
      path('root', views.root, name='root'),
      path('output/&lt;str:instance&gt;', views.output_page, name='output_page'),
  ]
  </code></pre>
  <p>There exists two pages in the application. In the <code>root</code> page there exists a form which when submitted should redirect to the <code>output_page</code>. But because the <code>output_page</code> is a dynamic url, I am not able to redirect.</p>
  <p>Here is my views file</p>
  <pre><code>def root(request):
      if request.method == 'POST':
  
          name = request.POST.get('name')
          job = request.POST.get('job')
  
          return redirect(&quot;test:output_page&quot;)
  
      return render(request, 'test/root.html')
  
  def output_page(request, instance):
  
      record = Object.objects.all(Instance_id=instance)
  
      return render(request, 'test/output_page.html', {'record': record})
  </code></pre>
  <p>Here is the Model</p>
  <pre><code>class Object(models.Model):
      Name = models.CharField(max_length=200, null=True, blank=True)
      Job = models.CharField(max_length=200, default=&quot;&quot;)
      Instance_id = models.CharField(max_length=200)
  </code></pre>
  <p>When the redirect happens I want the url to be as follows</p>
  <pre><code>http://127.0.0.1:8000/output/test-001
  </code></pre>
  <p>where <code>test-001</code> is the instance_id in the model.</p>
  <p>The output_page should filter all the data in the model with instance_id <code>test-001</code></p>