add first template for location_data object

This commit is contained in:
Robert Einsle 2017-01-09 10:59:46 +01:00
parent d8df0dec1c
commit 1d0da1eb27
4 changed files with 33 additions and 1 deletions

View File

@ -1,3 +1,12 @@
{% load static %}
<html>
<head>
<title>Test</title>
<link rel="stylesheet" type="text/css" href="{% static 'billard/css/bootstrap.css' %}" />
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>
<link rel="stylesheet" type="text/css" href="{% static 'billard/css/bootstrap.min.css' %}" />

View File

@ -0,0 +1,15 @@
{% extends 'billard/base.html' %}
{% block content %}
{% if object_list %}
<ul>
{% for location_data in object_list %}
<li><a href="/location_data/{{ location_data.id }}/">{{ location_data.location_id }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>No data available.</p>
{% endif %}
{% endblock %}

View File

@ -9,5 +9,6 @@ router.register(r'tables', views.TableViewSet)
router.register(r'location_data', views.LocationDataViewSet)
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'),
url(r'api/v1/', include(router.urls)),
]

View File

@ -1,5 +1,7 @@
from billard.serializers import *
from .models import LocationData
from rest_framework import viewsets
from django.views import generic
class ClientViewSet(viewsets.ModelViewSet):
@ -20,3 +22,8 @@ class TableViewSet(viewsets.ModelViewSet):
class LocationDataViewSet(viewsets.ModelViewSet):
queryset = LocationData.objects.all()
serializer_class = LocationDataSerializer
class IndexView(generic.ListView):
model = LocationData