{"body":"# Model\nclass Node(models.Model):\n    hostname = models.CharField(max_length=255, unique=True)\n#-- CUT FOR BREVITY --\n    site = models.ForeignKey(Site, on_delete=models.SET_NULL, null=True)\n\nclass Site(models.Model):\n    name = models.CharField(max_length=255, unique=True)\n#-- CUT FOR BREVITY --\n\n    def __str__(self):\n        return self.name\n\n\n# View\nclass IndexView(LoginRequiredMixin, generic.ListView):\n    template_name = \"nodes/index.djhtml\"\n    context_object_name = 'all_nodes'\n\n    def get_queryset(self):\n        return Node.objects.all()\n\n# Template\n{% extends 'base/base.djhtml' %}\n{% block content %}\n#-- CUT FOR BREVITY --\n                         {% if all_nodes %}\n                            {% regroup all_nodes by site as nodes %}\n\n                            {% for site in nodes %}\n                                <h3>site {{ nodes.grouper }}</h3>\n                            <table class=\"table table-bordered table-striped\">\n                                <thead>\n                                    <tr>\n                                        <th>#</th>\n                                        <th>hostname</th>\n                                        <th>driver</th>\n                                        <th>group</th>\n                                        <th></th>\n                                    </tr>\n                                </thead>\n                                <tbody>\n                                    {% for node in nodes.list %}\n                                        <tr>\n                                            <td>{{ node.id }}</td>\n                                            <td>{{ node.hostname }}</td>\n                                            <td>{{ node.driver }}</td>\n                                            <td>{{ node.group.name }}</td>\n                                            <td><a href=\"{% url 'nodes:detail' pk=node.id %}\"><button type=\"button\" class=\"btn btn-primary btn-xs\"><i class=\"glyphicon glyphicon-eye-open\"></i> view</button></a></td>\n                                        </tr>\n                                    {% endfor %}\n                                </tbody>\n                            </table>\n                            {% endfor %}\n                        {% else %}\n                            <p>no nodes available</p>\n                        {% endif %}\n{% endblock %}\n","name":"","extension":"txt","url":"https://www.irccloud.com/pastebin/OeIjALuj","modified":1532968243,"id":"OeIjALuj","size":2391,"lines":58,"own_paste":false,"theme":"","date":1532968243}