| 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
 
- # Create your views here.
 
- 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): # HttRequest
 
-     # t = render_to_string('women/index.html')
 
-     # return HttpResponse(t)
 
-     # data = {'title': 'главная страница?',
 
-     #         'menu': menu,
 
-     #         'float': 234.465,
 
-     #         'lst': [1, 2, 'abc', True],
 
-     #         'set': {1, 2, 3, 4, 5},
 
-     #         'dict': {'key_1': 'value_1', 'key_2': 'value_2'},
 
-     #         'obj': MyClass(10, 20),
 
-     #         'url': slugify("The main page"),
 
-     # }
 
-     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>")
 
 
  |