I have created a model, views and templates like so:
MODEL
project_choices = (
('Speaker', (
('help', 'Freedom'),
)),
('Money', (
('invest', 'Investment'),
)
),
(
'Children', (
('mc', 'Mother & Child'),
)
),
)
class Blog(models.Model):
title = models.CharField(max_length=250)
description = CKEditor5Field('Text', null=True)
limitation = models.CharField(
null=True, max_length=50, choices=project_choices)
def __str__(self):
return self.title
Now the VIEW
def view_portfolio(request):
blog= Blog.objects.filter(limitation=['help','invest,'mc']
template = 'blog/blog.html'
context = {'blog': blog}
return render(request, template, context)
then the hmtl template
{% for blog in blog%}
{% if blog.limitation['help'] %}**
<div class="col-lg-4 col-md-6">
<div class="help-wrap">
<img src="{{blog.featured}}" class="img-fluid" alt="">
<div class="blog-info">
<h4>{{blog.title}}</h4>
<p></p>
<div class="help-links">
<a href="{{blog.featured}}" data-gall="blogGallery" class="venobox" title="{{blog.title}}"><i class="bx bx-plus"></i></a>
<a href="blog-details.html" title="More Details"><i class="bx bx-link"></i></a>
</div>
</div>
</div>
</div>
{% endif %}
{% if blog.limitation['invest'] %}**
<div class="col-lg-4 col-md-6">
<div class="invest-wrap">
<img src="{{blog.featured}}" class="img-fluid" alt="">
<div class="blog-info">
<h4>{{blog.title}}</h4>
<p></p>
<div class="invest-links">
<a href="{{blog.featured}}" data-gall="blogGallery" class="venobox" title="{{blog.title}}"><i class="bx bx-plus"></i></a>
<a href="blog-details.html" title="More Details"><i class="bx bx-link"></i></a>
</div>
</div>
</div>
</div>
{% endif %}
{% if blog.limitation['mc'] %}**
<div class="col-lg-4 col-md-6">
<div class="mc-wrap">
<img src="{{blog.featured}}" class="img-fluid" alt="">
<div class="blog-info">
<h4>{{blog.title}}</h4>
<p></p>
<div class="mc-links">
<a href="{{blog.featured}}" data-gall="blogGallery" class="venobox" title="{{blog.title}}"><i class="bx bx-plus"></i></a>
<a href="blog-details.html" title="More Details"><i class="bx bx-link"></i></a>
</div>
</div>
</div>
</div>
{% endif %}
{%endfor%}
My goal is to show blogs based on ONLY the particular limitation as the chosen choice please how can I achieve this?
I am using django3
NOTE: I have updated the query based on @KenWhitesell 's instruction after testing it I now put all the expected limitations in the list so that output will be shown for each tab based on the particular limitation.