diff --git a/inventory/templates/base.html b/inventory/templates/base.html
index ac1c614..0d507b9 100644
--- a/inventory/templates/base.html
+++ b/inventory/templates/base.html
@@ -29,6 +29,9 @@
+
+
+
diff --git a/inventory/templates/inventory/tag_detail.html b/inventory/templates/inventory/tag_detail.html
new file mode 100644
index 0000000..d398b41
--- /dev/null
+++ b/inventory/templates/inventory/tag_detail.html
@@ -0,0 +1,118 @@
+{% extends "base.html" %}
+{% load static %}
+
+{% block title %}Tag {{ tag.name }}{% endblock %}
+
+{% block header_bar %}
+
+ {{ tag.name }}
+ {{ tag.description}}
+{% endblock %}
+
+{% block header_icons %}
+ {% if user.is_staff %}
+
+
+
+ {% endif %}
+{% endblock %}
+
+{% block content %}
+ {% if tag.workshop_set.count > 0 %}
+ Workshops
+
+
+ {% for workshop in tag.workshop_set.all %}
+
+
+ {{ workshop.name }}
+ |
+
+ {% if user.is_staff %}
+
+ {% endif %}
+ |
+
+ {% endfor %}
+
+
+ {% endif %}
+
+ {% if tag.box_set.count > 0 %}
+ Boxes
+
+
+ {% for box in tag.box_set.all %}
+
+
+ {{ box.name }}
+ |
+
+ {% if user.is_staff %}
+
+ {% endif %}
+ |
+
+ {% endfor %}
+
+
+ {% endif %}
+
+ {% if tag.distributor_set.count > 0 %}
+ Distributors
+
+
+ {% for distributor in tag.distributor_set.all %}
+
+
+ {{ distributor.name }}
+ |
+
+ {% if user.is_staff %}
+
+ {% endif %}
+ |
+
+ {% endfor %}
+
+
+ {% endif %}
+
+ {% if tag.manufacturer_set.count > 0 %}
+ Manufacturers
+
+
+ {% for manufacturer in tag.manufacturer_set.all %}
+
+
+ {{ manufacturer.name }}
+ |
+
+ {% if user.is_staff %}
+
+ {% endif %}
+ |
+
+ {% endfor %}
+
+
+ {% endif %}
+
+ {% if items %}
+ Items
+ {% url 'tag-detail' tag.id as this_url %}
+ {% include "inventory/pagination.html" with url=this_url id="items_paginator_top" param="item" paginator=items %}
+ {% include "inventory/item_list.html" with items=items show_manufacturer=1 show_distributor=1 %}
+ {% include "inventory/pagination.html" with url=this_url id="items_paginator_bottom" param="item" paginator=items %}
+ {% endif %}
+
+ {% if tag.formfactor_set.count > 0 %}
+ Form factors
+
+ {% for formfactor in tag.formfactor_set.all %}
+ - {{ formfactor.name }}
+ {% endfor %}
+
+ {% endif %}
+
+{% endblock %}
\ No newline at end of file
diff --git a/inventory/templates/inventory/tag_list.html b/inventory/templates/inventory/tag_list.html
new file mode 100644
index 0000000..93b3d51
--- /dev/null
+++ b/inventory/templates/inventory/tag_list.html
@@ -0,0 +1,58 @@
+{% extends "base.html" %}
+{% load static %}
+{% load formatstring %}
+
+{% block title %}Tags{% endblock %}
+
+{% block header_bar %}
+ Tags
+{% endblock %}
+
+{% block content %}
+
+
+
+ {% for tag in object_list %}
+ - {{ tag.name }}
+ {% empty %}
+ No tags
+ {% endfor %}
+
+
+ {% if user.is_staff %}
+ Create new tag...
+ {% endif %}
+
+{% endblock %}
\ No newline at end of file
diff --git a/inventory/views/tag.py b/inventory/views/tag.py
index 1cf10d4..85bdbfc 100644
--- a/inventory/views/tag.py
+++ b/inventory/views/tag.py
@@ -1,13 +1,29 @@
-from django.views import View
+from django.core.paginator import Paginator
+from django.db.models import Q
from django.contrib.auth.decorators import login_required
from django.utils.decorators import method_decorator
from django.views.generic import ListView, DetailView
+from django.conf import settings
-from inventory.models import Tag
+from inventory.models import Tag, Item
-class TagView(View):
- pass
+@method_decorator(login_required, name='dispatch')
+class TagView(DetailView):
+ context_object_name = 'tag'
+ queryset = Tag.objects.all().prefetch_related('workshop_set', 'box_set', 'distributor_set', 'manufacturer_set', 'formfactor_set')
+
+ def get_context_data(self, *args, object_list=None, **kwargs):
+ result = super().get_context_data(*args, object_list=object_list, **kwargs)
+ p = self.request.GET.get("item_page", 1)
+ direct_tags = Q(tags__in=[self.get_object()])
+ formfactor_tags = Q(form_factor__tags__in=[self.get_object()])
+ items = Item.objects.filter(direct_tags | formfactor_tags).distinct().select_related('container', 'manufacturer')
+ paginator = Paginator(items, getattr(settings, "PAGE_SIZE", 10))
+ result.update({
+ "items": paginator.get_page(p)
+ })
+ return result
@method_decorator(login_required, name='dispatch')
class TagListView(ListView):