Commit 9d642eeb authored by alexandre's avatar alexandre

Django list view for the scores

parent 651d0cb5
......@@ -11,3 +11,6 @@ class Score(models.Model):
def __str__(self):
return self.title
def get_absolute_url(self):
return "/playground/score/#{}".format(self.id)
......@@ -175,7 +175,7 @@ window.W = window.W || {};
alt_div.hide();
this.render();
return false;
}else{
} else{
var $target = $(e.target);
var alt_div = $target.parent();
alt_div.hide();
......
<h1>scores</h1>
<ul>
{% for score in object_list %}
<li><a href="{{ score.get_absolute_url }}">{{ score.title }}</a></li>
{% empty %}
<li>No scores yet.</li>
{% endfor %}
</ul>
from django.conf.urls import url
from playground.views import ScoreDetailView, SandboxView
from playground.views import ScoreDetailView, ScoreListView, SandboxView
urlpatterns = [
url(r'^sandbox/$', SandboxView.as_view(), name='sandbox'),
url(r'^score/', ScoreDetailView.as_view(), name='score-detail'),
# url(r'^score/(?P<pk>\d+)/$', ScoreDetailView.as_view(), name='score-detail'),
url(r'^$', ScoreListView.as_view(), name='score-list'),
]
from django.views.generic import DetailView
from django.views.generic.list import ListView
from django.views.generic.base import TemplateView
from rest_framework import viewsets
from .models import Score
......@@ -13,6 +13,12 @@ class ScoreViewSet(viewsets.ModelViewSet):
serializer_class = ScoreSerializer
class ScoreListView(ListView):
"""
"""
model = Score
class ScoreDetailView(TemplateView):
"""
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment