-
-
+
+
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