Explorar o código

Really basic list view

Colin Powell %!s(int64=3) %!d(string=hai) anos
pai
achega
57f9171192
Modificáronse 4 ficheiros con 24 adicións e 1 borrados
  1. 3 0
      emus/urls.py
  2. 8 0
      games/urls.py
  3. 1 1
      games/views.py
  4. 12 0
      templates/games/game_list.html

+ 3 - 0
emus/urls.py

@@ -1,6 +1,9 @@
 from django.contrib import admin
 from django.urls import path, include
 
+from games import views as games_views
+
 urlpatterns = [
     path("admin/", admin.site.urls),
+    path("", games_views.GameList.as_view()),
 ]

+ 8 - 0
games/urls.py

@@ -1 +1,9 @@
 #!/usr/bin/env python3
+from django.urls import path
+
+# importing views from views..py
+from .views import CodeList
+
+urlpatterns = [
+    path("", CodeList.as_view()),
+]

+ 1 - 1
games/views.py

@@ -2,7 +2,7 @@ from django.shortcuts import render
 
 from django.views.generic import ListView
 
-from ..games.models import Game
+from .models import Game
 
 
 class GameList(ListView):

+ 12 - 0
templates/games/game_list.html

@@ -0,0 +1,12 @@
+{% extends "base.html" %}
+
+{% block title %}Game list{% endblock %}
+
+{% block content %}
+
+    <ul>
+    {% for game in object_list %}
+        <li>{{game}}</li>
+    {% endfor %}
+    </uk>
+{% endblock %}