diff --git a/articles/static/index.css b/articles/static/index.css index c7a06a0..d670d2a 100644 --- a/articles/static/index.css +++ b/articles/static/index.css @@ -29,6 +29,11 @@ a { padding-right: 15px; } +.one-post:hover { + background: #334661; + transition: .3s ease-in; +} + .article-created-date { font-size: 12px; } @@ -37,4 +42,18 @@ a { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); +} + +.post-link { + text-decoration: none; + color: unset; +} + +.article-meta { + display: flex; + justify-content: space-between; +} + +.article-header { + margin: 0; } \ No newline at end of file diff --git a/articles/templates/archive.html b/articles/templates/archive.html index 8ccd559..a0f0a02 100644 --- a/articles/templates/archive.html +++ b/articles/templates/archive.html @@ -15,14 +15,16 @@
{% for post in posts %} -
-

{{ post.title }}

- + {% endfor %}
diff --git a/articles/templates/article.html b/articles/templates/article.html new file mode 100644 index 0000000..504d8ea --- /dev/null +++ b/articles/templates/article.html @@ -0,0 +1,29 @@ + + + + + + {{ post.title }} + {% load static %} + + + + +
+ +

Всё про IT

+
+

{{ post.title }}

+ +
+

{{ post.author.first_name }}

+

{{ post.created_date }}

+
+ +
+ {{ post.text|linebreaks }} +
+ +

← Назад к списку статей

+ + \ No newline at end of file diff --git a/articles/views.py b/articles/views.py index 07b6536..99eb4ac 100644 --- a/articles/views.py +++ b/articles/views.py @@ -1,5 +1,13 @@ from .models import Article from django.shortcuts import render +from django.http import Http404 def archive(request): return render(request, 'archive.html', {"posts": Article.objects.all()}) + +def get_article(request, article_id): + try: + post = Article.objects.get(id=article_id) + return render(request, 'article.html', {"post": post}) + except Article.DoesNotExist: + raise Http404 diff --git a/blog/urls.py b/blog/urls.py index c1def91..431f1a5 100644 --- a/blog/urls.py +++ b/blog/urls.py @@ -15,10 +15,11 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import path, re_path from articles import views urlpatterns = [ path('admin/', admin.site.urls), path('', views.archive), + re_path(r'^article/(?P\d+)$', views.get_article, name='get_article'), ]