I have looked all over not sure if I am searching to broadly.
I want to essentially only show data to a user if that user is linked to the data. Currently it shows all data.
Example of similar function.
{% for group in request.user.groups.all %}
{% if group.name == 'General User' %}
{% for project in project_card_list %}
{% for u in project.assigned_users.all %}
{% if u == user %}
This is just a quick example of what I want, I was able to display the data this way but was wanting to clean it up and have it show in a django table2 table instead.
Table code:
class ProjectTable(tables.Table):
class Meta:
model = Project
template_name = "django_tables2/bootstrap.html"
fields = ("name", "project_lead", "start_date", "end_date", "description")
exclude = ("project_id", "assigned_users",)
View:
@login_required(login_url='login_register')
def projects_page(request):
table = ProjectTable(Project.objects.all())
return render(request, 'projects.html', {'table': table})