1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- from django.shortcuts import render, redirect
- from django.http import HttpResponse, HttpResponseNotFound, Http404, HttpResponseRedirect
- from django.urls import reverse
- from django.template.loader import render_to_string
- from django.template.defaultfilters import slugify
- menu = [{'title': "О сайте", 'url_name': 'about'},
- {'title': "Добавить статью", 'url_name': 'add_page'},
- {'title': "Обатная связь", 'url_name': 'contact'},
- {'title': "Войти", 'url_name': 'login'}
- ]
- data_db = [
- {'id': 1, 'title': 'Анджелина Джоли', 'content': 'Биография Анджелины Джоли', 'is_published': True },
- {'id': 2, 'title': 'Марго Робби', 'content': 'Биография Марго Робби', 'is_published': False },
- {'id': 3, 'title': 'Джулия Робертс', 'content': 'Биография Джулия Робертс', 'is_published': True },
- ]
- def index(request):
-
-
-
-
-
-
-
-
-
-
-
- data = {'title': 'Главная страница',
- 'menu': menu,
- 'posts': data_db,
- }
-
- return render(request, 'women/index.html', context=data)
- def about(request):
- return render(request, 'women/about.html', {'title': 'О сайте'})
- def show_post(request, post_id):
- return HttpResponse(f"Отображение статьи с id = {post_id}")
- def addpage(request):
- return HttpResponse("Добавление статьи")
- def contact(request):
- return HttpResponse("Обратная связь")
- def login(request):
- return HttpResponse("Авторизация")
- def page_not_found(request, exception):
- return HttpResponseNotFound("<h1>Страница не найдена</h1>")
|