diff --git a/catalog/templates/catalog/detail.html b/catalog/templates/catalog/detail.html index 73b6f54..8f440fc 100644 --- a/catalog/templates/catalog/detail.html +++ b/catalog/templates/catalog/detail.html @@ -1,45 +1,24 @@ - - - - Книжный магазин - - - -
- -
-
-
-
-
-
-
- Название книги -
-
-
Название: Нащвние книги
-
Название на английском: Book name
-
Автор: Автор
-
Количество страниц: 256
-
Год выпуска: 2018
-
Описание книги
-
-
+{% extends 'base.html' %} +{% load static %} + +{% block content %} +
+
+
+
+
+ Название книги +
+
+
Название: {{ book.name }}
+
Название на английском: {{ book.name_eng }}
+
Автор: {{ book.author }}
+
Количество страниц: {{ book.pages }}
+
Год выпуска: {{ book.pub_year }}
+
{{ book.description }}
-
- - - \ No newline at end of file + + +{% endblock %} diff --git a/catalog/views.py b/catalog/views.py index 7ee56af..75652d8 100644 --- a/catalog/views.py +++ b/catalog/views.py @@ -2,6 +2,7 @@ from django.shortcuts import render from catalog.data import BOOKS + def detail(request, id): books = list(filter(lambda b: b['id'] == id, BOOKS)) if len(books) == 0: diff --git a/main/templates/main/index.html b/main/templates/main/index.html index 543a753..8b51714 100644 --- a/main/templates/main/index.html +++ b/main/templates/main/index.html @@ -1,44 +1,28 @@ - - - - Книжный магазин - - - -
- -
-
+{% extends 'base.html' %} +{% load static %} + +{% block content %}
+ {% for book in books %}
- Название книги -
Название
-
-
Автор
- Подробнее -
-
-
Заказать
-
Нет в наличии
-
+ Название книги +
{{ book.name }}
+
+
{{ book.author }}
+ Подробнее +
+
+ {% if book.is_available %} +
Заказать
+ {% else %} +
Нет в наличии
+ {% endif %} +
+ {% endfor %}
-
- - - \ No newline at end of file +{% endblock %} diff --git a/market/settings.py b/market/settings.py index 8629e50..54cdda6 100644 --- a/market/settings.py +++ b/market/settings.py @@ -57,7 +57,7 @@ TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], + 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..d596380 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,28 @@ +{% load static %} + + + + Книжный магазин + + + + + +
+ +
+
{% block content %}{% endblock %}
+ + +