From a378414ea33dd309ad3e68e5983a3468ab84294f Mon Sep 17 00:00:00 2001 From: root Date: Thu, 9 Oct 2025 13:42:44 +0300 Subject: [PATCH] fix: article creation --- articles/static/index.css | 4 ++++ articles/templates/new_article.html | 4 +++- articles/views.py | 3 +++ db.sqlite3 | Bin 188416 -> 188416 bytes delete.sh | 1 + 5 files changed, 11 insertions(+), 1 deletion(-) create mode 100755 delete.sh diff --git a/articles/static/index.css b/articles/static/index.css index e33614a..170f448 100644 --- a/articles/static/index.css +++ b/articles/static/index.css @@ -70,4 +70,8 @@ form { .text { min-height: 500px; +} + +.error { + color: red; } \ No newline at end of file diff --git a/articles/templates/new_article.html b/articles/templates/new_article.html index c701554..3d7daaf 100644 --- a/articles/templates/new_article.html +++ b/articles/templates/new_article.html @@ -20,7 +20,9 @@ - {{ form.errors }} +
+ {{ error }} +

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

diff --git a/articles/views.py b/articles/views.py index 2eabd47..c51e1fd 100644 --- a/articles/views.py +++ b/articles/views.py @@ -19,11 +19,14 @@ def create_post(request): 'text': request.POST["text"], 'title': request.POST["title"] } if form["text"] and form["title"]: + print('try') try: article = Article.objects.create(text=form["text"], title=form["title"], author=request.user) return redirect('get_article', article_id=article.id) except: return render(request, 'article_invalid_name.html') + else: + return render(request, 'new_article.html', {'form': form, 'error': 'Введите название и текст статьи!'}) if not request.user.is_anonymous: return render(request, 'new_article.html') diff --git a/db.sqlite3 b/db.sqlite3 index eda65f29b574bbcc18ad6feeec99d6b0273a1f2b..a898b659dad04d60a9b8e450ef7c3f0f4852f5e6 100644 GIT binary patch delta 978 zcmah`O=ufO7~Nep7|B{q4erH_!z5|34VJRfu6|Zf@XE66#FkVil7G~Lt7=!WtVp|A ztz^liSdv2%h(ntuCA5?TLZQ9Mvf`|%Q^$~7E}4a1+KL`hC?QZN?V*=KJF*G%QaS_Q z&%k@%d*9R!dTR&0AHPl}ZX6#c6Rme&J3|h%%V%O^eLQqBeva|GTn?7yI2Y6YQ67O7 ziq;8Rht{p1wCW#P+qb?rO|CaiQOCj?7lgc;^>U&!n`0}L^rbW_gMpv^!Jdn1BvDneN-C^`4c+QPC{ zN+?NoGLg7Av5*iK6tVht?tFFCn+ula=lS)yRMo47l_@ba<&7!DxZ+#LEV15dV5Q32 zlYzyEGg62JCIw$Ucy=nv2-<3@@Lt9}9`>9o`X)Rxn!LI=zgQWc%W(Yi*_dZdn&MM@ zG#K|g%O05v`!B_%ST->ib85@W3RlT%YxZ(9u9fUzCAT6BRoszuO6IkEFf={uVq9*! zld-$le=pGI@^J0Wong{K0i6IHpaZ?#r(6LyKW(0R^9@s&{J-T<8=a=!X_CWZnBp-3 zo`J{UOHA<@xc$}N(p-nD`jQ~OVP}jks0Z)A_|(< z8)E}K#N~HRng>zKxMnnr%~6QsHE7h)KGM;Bw1xIYA^H~QM@9|pqKBBXHVX6ArL?T( z;agBpwQTC56vEx`2yH=I5IsWsMg!v?cFSGkDu!G&HlZqMCAEN4L6p>Chr=oOl?yiW#_y dId_8Kc7Y2_3Y-%s^f2z4*tl(b@hzraRsj1KU%>zX diff --git a/delete.sh b/delete.sh new file mode 100755 index 0000000..d25d075 --- /dev/null +++ b/delete.sh @@ -0,0 +1 @@ +sqlite3 db.sqlite3 < delete.sql