diff --git a/.idea/mysite.iml b/.idea/mysite.iml index 314a804..a05bf1e 100644 --- a/.idea/mysite.iml +++ b/.idea/mysite.iml @@ -7,6 +7,7 @@ + + - - + + true + DEFINITION_ORDER - @@ -153,8 +168,6 @@ - - @@ -169,7 +182,7 @@ @@ -178,10 +191,24 @@ + + - + @@ -311,7 +340,21 @@ - + + @@ -472,6 +518,7 @@ 1473370898720 - + - - + + - - + + + - + @@ -505,7 +553,6 @@ - @@ -528,24 +575,24 @@ - + - + - + - + @@ -555,7 +602,7 @@ - + @@ -563,7 +610,7 @@ - + @@ -571,14 +618,14 @@ - + - + @@ -588,7 +635,7 @@ - + @@ -596,31 +643,31 @@ - + - + - + - + - + @@ -630,7 +677,7 @@ - + @@ -638,7 +685,7 @@ - + @@ -646,14 +693,14 @@ - + - + @@ -663,7 +710,7 @@ - + @@ -671,31 +718,31 @@ - + - + - + - + - + @@ -705,7 +752,7 @@ - + @@ -713,7 +760,7 @@ - + @@ -721,14 +768,14 @@ - + - + @@ -738,7 +785,7 @@ - + @@ -746,14 +793,14 @@ - + - + @@ -761,14 +808,14 @@ - + - + @@ -776,31 +823,31 @@ - + - + - + - + - + @@ -808,31 +855,31 @@ - + - + - + - + - + @@ -840,107 +887,107 @@ - + - + - + - + - + - - - + + - + - - - - - + + - + - - - + + - + - - + + + - + - - + + + + + - + - - + + + - + - - + + - + - - + + - + - - + + - - + + diff --git a/blog/__pycache__/__init__.cpython-34.pyc b/blog/__pycache__/__init__.cpython-34.pyc new file mode 100644 index 0000000..c4cd84f Binary files /dev/null and b/blog/__pycache__/__init__.cpython-34.pyc differ diff --git a/blog/__pycache__/admin.cpython-34.pyc b/blog/__pycache__/admin.cpython-34.pyc new file mode 100644 index 0000000..540db69 Binary files /dev/null and b/blog/__pycache__/admin.cpython-34.pyc differ diff --git a/blog/__pycache__/forms.cpython-34.pyc b/blog/__pycache__/forms.cpython-34.pyc new file mode 100644 index 0000000..bf6ac62 Binary files /dev/null and b/blog/__pycache__/forms.cpython-34.pyc differ diff --git a/blog/__pycache__/models.cpython-34.pyc b/blog/__pycache__/models.cpython-34.pyc new file mode 100644 index 0000000..d98394e Binary files /dev/null and b/blog/__pycache__/models.cpython-34.pyc differ diff --git a/blog/__pycache__/urls.cpython-34.pyc b/blog/__pycache__/urls.cpython-34.pyc new file mode 100644 index 0000000..4cfd0b5 Binary files /dev/null and b/blog/__pycache__/urls.cpython-34.pyc differ diff --git a/blog/__pycache__/views.cpython-34.pyc b/blog/__pycache__/views.cpython-34.pyc new file mode 100644 index 0000000..2831c16 Binary files /dev/null and b/blog/__pycache__/views.cpython-34.pyc differ diff --git a/blog/migrations/__pycache__/0001_initial.cpython-34.pyc b/blog/migrations/__pycache__/0001_initial.cpython-34.pyc new file mode 100644 index 0000000..1fb7a08 Binary files /dev/null and b/blog/migrations/__pycache__/0001_initial.cpython-34.pyc differ diff --git a/blog/migrations/__pycache__/__init__.cpython-34.pyc b/blog/migrations/__pycache__/__init__.cpython-34.pyc new file mode 100644 index 0000000..d94da2b Binary files /dev/null and b/blog/migrations/__pycache__/__init__.cpython-34.pyc differ diff --git a/blog/templates/blog/base.html b/blog/templates/blog/base.html index d34edac..301dbe9 100644 --- a/blog/templates/blog/base.html +++ b/blog/templates/blog/base.html @@ -14,9 +14,10 @@
diff --git a/blog/templates/blog/post_detail.html b/blog/templates/blog/post_detail.html index b3cbe4a..84ab638 100644 --- a/blog/templates/blog/post_detail.html +++ b/blog/templates/blog/post_detail.html @@ -8,6 +8,10 @@
{% endif %} + {% if user.is_authenticated %} + + {% endif %}

{{ post.title }}

{{ post.text|linebreaksbr }}

diff --git a/blog/urls.py b/blog/urls.py index 2ac7fd9..803f1ec 100644 --- a/blog/urls.py +++ b/blog/urls.py @@ -2,7 +2,8 @@ from . import views urlpatterns = [ - url(r'^$', views.post_list, name='post_list'), - url(r'^post/(?P\d+)/$', views.post_detail, name='post_detail'), - url(r'^post/new/$', views.post_new, name='post_new'), + url(r'^$', views.post_list, name='post_list'), + url(r'^post/(?P\d+)/$', views.post_detail, name='post_detail'), + url(r'^post/new/$', views.post_new, name='post_new'), + url(r'^post/(?P\d+)/edit/$',views.post_edit,name='post_edit'), ] \ No newline at end of file diff --git a/blog/views.py b/blog/views.py index f43dd7b..7e2fb8a 100644 --- a/blog/views.py +++ b/blog/views.py @@ -28,4 +28,18 @@ def post_new(request): return redirect('post_detail', pk=post.pk) else: form = PostForm() - return render(request, 'blog/post_edit.html', {'form': form}) \ No newline at end of file + return render(request, 'blog/post_edit.html', {'form': form}) + +def post_edit(request,pk): + post = get_object_or_404(Post, pk=pk) + if request.method == 'POST': + form = PostForm(request.POST,instance=post) + if form.is_valid(): + post = form.save(commit=False) + post.author = request.user + post.published_date = timezone.now() + post.save() + return redirect('post_detail' , pk=post.pk) + else: + form =PostForm(instance= post) + return render(request,'blog/post_edit.html',{'form':form}) diff --git a/db.sqlite3 b/db.sqlite3 index c7eb552..00542f7 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/mysite/__pycache__/__init__.cpython-34.pyc b/mysite/__pycache__/__init__.cpython-34.pyc new file mode 100644 index 0000000..c43b840 Binary files /dev/null and b/mysite/__pycache__/__init__.cpython-34.pyc differ diff --git a/mysite/__pycache__/settings.cpython-34.pyc b/mysite/__pycache__/settings.cpython-34.pyc new file mode 100644 index 0000000..09bc76c Binary files /dev/null and b/mysite/__pycache__/settings.cpython-34.pyc differ diff --git a/mysite/__pycache__/urls.cpython-34.pyc b/mysite/__pycache__/urls.cpython-34.pyc new file mode 100644 index 0000000..ae10b03 Binary files /dev/null and b/mysite/__pycache__/urls.cpython-34.pyc differ diff --git a/mysite/__pycache__/wsgi.cpython-34.pyc b/mysite/__pycache__/wsgi.cpython-34.pyc new file mode 100644 index 0000000..3d1908b Binary files /dev/null and b/mysite/__pycache__/wsgi.cpython-34.pyc differ