Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- urls:
- from django.urls import path
- from . import views
- from accounts import views as acc_views
- from articles import views as art_views
- urlpatterns = [
- path('', views.index),
- path('accounts/sign-up', acc_views.sign_up),
- path('accounts/sign-in', acc_views.sign_in),
- path('accounts/my-account', acc_views.my_account),
- path('accounts/friends/<str:user>', acc_views.get_friends),
- path('articles/dashboard', art_views.dashboard),
- path('articles/dashboard/<int:year>', art_views.dashboard),
- path('articles/<int:id>', art_views.article_by_id),
- path('articles/tag/<str:tag>', art_views.articles_by_tag),
- path('articles/search', art_views.search)
- # добавьте новый путь сюда
- ]
- views:
- def search(request):
- if request.method == 'GET':
- name = request.GET['name'] # получите автора статьи из запроса
- year = int(request.GET['year']) # получите год из запроса
- found_articles = []
- for article in articles_list:
- # ... если автор и год совпадают с запрошенными
- if name == article[1] and year == article[2]:
- found_articles.append(article)
- beautiful_html = generate_html(found_articles)
- return HttpResponse(beautiful_html)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement