i think u forgot to configure model, please once configure and complete
check first

On Mon, Nov 22, 2021 at 4:36 PM Trippy Samurai <someshkandukuri...@gmail.com>
wrote:

> Thanks David for the idea i appreciate it i have gone with last way of
> doing things but it doesnt render anything on data
>
> Pls correct my code below
>
>
>
> *views.py:*
>
> class DeveloperTicketView(TemplateView):
> template_name = 'app/ticket_view.html'
> ticket = Ticket.objects.all()
> extra_content = {'ticket_type':ticket}
>
> def get_context_data(self, **kwargs):
> context = super().get_context_data(**kwargs)
> context['open_tickets'] = Ticket.objects.filter(status = 'Opened')
> context['accepted_tickets'] = Ticket.objects.filter(status =
> 'Accepted',accepted_by = self.request.user)
> context['completed_tickets'] = Ticket.objects.filter(status =
> 'Completed',accepted_by = self.request.user)
> context['closed_tickets'] = Ticket.objects.filter(status =
> 'Closed',accepted_by = self.request.user)
> return context
>
>
>
> ticket_view.html
>
> {% extends 'app/base.html' %}
>
> {% block body %}
> {% for tickets in ticket_type%}
> {% if tickets.status == "Opened" %}
> <table class="table table-bordered">
> <thead>
> <tr>
> <th>ID</th>
> <th>Status</th>
> <th>Created</th>
> <th>Title</th>
> <th>Description</th>
> </tr>
> </thead>
> <tbody>
> {% for ticket in open_tickets %}
> <tr>
> <td><a href="">{{ ticket.id }}</a></td>
> <td>{{ ticket.status }}</td>
> <td>{{ ticket.created_by }}</td>
> <td>{{ ticket.ticket_title }}</td>
> <td>{{ ticket.ticket_description }}</td>
> <td><a href="{% url 'accept_tickets' pk=ticket.id %}"> Accept</a>
> </tr>
> {% endfor %}
> </tbody></table>
> {% elif tickets.status == 'Accepted' %}
> <table class="table table-bordered">
> <thead>
> <tr>
> <th>ID</th>
> <th>Status</th>
> <th>Created by</th>
> <th>Title</th>
> <th>Description</th>
> </tr>
> </thead>
>
> <tbody>
> {% for ticket in accepted_tickets %}
> <tr>
> <td><a href="">{{ ticket.id }}</a></td>
> <td>{{ ticket.status }}</td>
> <td>{{ ticket.created_by }}</td>
> <td>{{ ticket.ticket_title }}</td>
> <td>{{ ticket.ticket_description }}</td>
> <td><a href="{% url 'mark_complete' pk=ticket.id %}">Complete</a>
> </tr>
> {% endfor %}
> </tbody></table>
>
> {% elif tickets.status == 'Completed' %}
>
> <table class="table table-bordered">
>
> <thead>
> <tr>
> <th>ID</th>
> <th>Status</th>
> <th>Created by</th>
> <th>Title</th>
> <th>Description</th>
> </tr>
> </thead>
>
> <tbody>
> {% for ticket in completed_tickets %}
> <tr>
> <td><a href="">{{ ticket.id }}</a></td>
> <td>{{ ticket.status }}</td>
> <td>{{ ticket.created_by }}</td>
> <td>{{ ticket.ticket_title }}</td>
> <td>{{ ticket.ticket_description }}</td>
> </tr>
> {% endfor %}
> {% else %}
> <table class="table table-bordered">
> <thead>
> <tr>
> <th>ID</th>
> <th>Status</th>
> <th>Created by</th>
> <th>Title</th>
> <th>Description</th>
> </tr>
> </thead>
>
> <tbody>
> {% for ticket in closed_tickets %}
> <tr>
> <td><a href="">{{ ticket.id }}</a></td>
> <td>{{ ticket.status }}</td>
> <td>{{ ticket.created_by }}</td>
> <td>{{ ticket.ticket_title }}</td>
> <td>{{ ticket.ticket_description }}</td>
> </tr>
> {% endfor %}
> {% endif %}
> {% endfor %}
> {% endblock %}
>
>
>
>
> On Monday, 22 November 2021 at 13:22:47 UTC+5:30 David Nugent wrote:
>
>> Well, there are several ways you can deal with that.
>>
>> Probably easiest is to override get_template() and switch the template
>> based on whatever type of ticket you're managing or you can change the
>> value of self.template_name based on the request.
>>
>> Or maybe you prefer a single template to deal with all cases with
>> conditional blocks where appropriate.
>>
>>
>> Regards,
>> David
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/786fa7af-0a81-4cf7-9a2e-c2fd2e9f0323n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/786fa7af-0a81-4cf7-9a2e-c2fd2e9f0323n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAOGms2_ZR_rrHuANSVAAA0Ca5ow9HVzLHQDVBf%3Dz2XjBEGTmYg%40mail.gmail.com.

Reply via email to