Django: Filtering query to a specific id
<p>I have a podcast management website where a user is able to setup his account and after that will be able to create multiple episode from that specific user. After an episode is done, a button will appear where he can see some links that is created automatically for the user to use. The problem I am having is that for every episode, I am trying to show the links for that specific one but it always keeps showing the links from the one I recently created and other episodes that were previously created.</p>

<p>This is the button where the user click when the episode has created the links:</p>

<pre><code>&lt;a class="btn btn-info box-shadow--6dp" href="{% url 'pf:episodereview' production_id=instance.id %}" role="button"&gt;&lt;i class="fa fa-link" aria-hidden="true"&gt;&lt;/i&gt;&amp;nbsp Review Links&lt;/a&gt;
</code></pre>

<p>The URL pattern in <code>urls.py</code>:</p>

<pre><code>url(r'^episodereview/(?P&lt;production_id&gt;[0-9]+)/$', views.EpisodeReview.as_view(), name="episodereview"),
</code></pre>

<p>This is what happens in <code>views.py</code>:</p>

<pre><code>class EpisodeReview(LoginRequiredMixin, ProductionRequiredMixin, ListView):
    template_name = 'pf/forms_episode_review.html'
    podcast = None

    def get(self, request, *args, **kwargs):
        production_id = kwargs.get('production_id', None)

        if production_id:
            production = Production.objects.filter(id=production_id).first()
            if not production:
                return self.handle_no_permission()

        return super(EpisodeReview, self).get(request, *args, **kwargs)

    def get_queryset(self):
        return Production.objects.filter(podcast=self.podcast)

    def get_success_url(self):
        return reverse('pf:dashboard')
</code></pre>

<p>And the template where everything is displayed:</p>

<pre><code>{% extends "pf/base.html" %}
{% load crispy_forms_tags %}


{% block content %}

&lt;br&gt;
&lt;br&gt;

&lt;div class="panel panel-default box-shadow--16dp col-sm-6 col-sm-offset-3"&gt;
&lt;div class="panel-body"&gt;

&lt;div class='row'&gt;
&lt;div class='col-sm-12'&gt;

&lt;h3&gt;&lt;i class="fa fa-wpforms pull-right" aria-hidden="true"&gt;&lt;/i&gt;Episode Review&amp;nbsp&lt;/h3&gt;

&lt;h5&gt;Following links are generated automatically with your accounts and can be used immediately.&lt;/h5&gt;

&lt;hr/&gt;

    {% if object_list %}

        &lt;table class='table'&gt;
            &lt;tbody&gt;
            {% for instance in object_list %}
                &lt;ul&gt;
                    &lt;li&gt;&lt;b&gt;Wordpress URL:&lt;/b&gt; {{ instance.wordpress_url }}&lt;/li&gt;
                    &lt;li&gt;&lt;b&gt;Wordpress Short URL:&lt;/b&gt; {{ instance.wordpress_short_url }}&lt;/li&gt;
                    &lt;li&gt;&lt;b&gt;Soundcloud Result URL:&lt;/b&gt;{{ instance.soundcloud_result_url }}&lt;/li&gt;
                    &lt;li&gt;&lt;b&gt;Youtube Result URL:&lt;/b&gt;{{ instance.youtube_result_url }}&lt;/li&gt;
                    &lt;li&gt;&lt;b&gt;Libsyn Result URL:&lt;/b&gt;{{ instance.libsyn_result_url }}&lt;/li&gt;
                &lt;/ul&gt;
            {% endfor %}
            &lt;/tbody&gt;
        &lt;/table&gt;
    {% endif %}
&lt;hr/&gt;
&lt;button type="submit" class="btn btn-info box-shadow--6dp"&gt;&lt;i class="fa fa-floppy-o" aria-hidden="true"&gt;&lt;/i&gt; &amp;nbspSave
&lt;/button&gt;

&lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;
&lt;/div&gt;

{% endblock %}
</code></pre>

<p>Welcome any suggestion!</p>

<p>You filter by the id in the get method, but then don't do anything with the result. When it comes to construct the template context, Django calls get_queryset, which only filters by self.podcast - which is None.</p>

<p>You should move that filter logic into get_queryset. And if you also want to filter by podcast, you should find a way to define that parameter too.</p>

python django django-templates django-views django-urls