Django QuerySet filter over string
<p>I have a models.py file with some rows and I would like to return on my HTML template all rows corresponding to my filter QuerySet.</p>

<pre><code>#models.py

def Test(request) :

    CarCollection = MyModel.objects.filter(car="old")

    context = {
        "CarCollection" : CarCollection
    }

    return render(request, 'car.html', context)
</code></pre>

<p>My html template looks like :</p>

<pre><code>&lt;!-- car.html --&gt;

{% block content %} 
&lt;ul&gt;
{% for car in CarCollection %}
  &lt;li&gt;{{ car }}&lt;/li&gt;
{% endfor %}
&lt;/ul&gt;

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

<p>But my objects looks like :</p>

<pre><code>Volvo_old_car
Audi_old_car
Nissan_new_car
old_Bentley
</code></pre>

<p>So I would like to isolate a string in my object (<code>old</code> for example) and return all objects with this string. But this string could be at the beginning, at the middle or at the end.</p>

<p>The filter will return :</p>

<pre><code>Volvo_old_car
Audi_old_car
old_bentley
</code></pre>

<p>I need to use Regex to do that ?</p>

<p>Thank you by advance</p>