Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions mysite/blog/static/blog/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ h4,
h6 {
color: #444444;
}

ul {
margin: 0;
}

ul {
margin: 0;
list-style: none;
}

ul li:before {
content: "\00BB \0020";
}

.bg-steel {
background-color: #5f788a;
Expand Down Expand Up @@ -293,6 +298,7 @@ label {
z-index: 0;
visibility: hidden;
}

}
.slider > #input-slide-autoplay:checked ~ .slide-description > .slide-0 {
animation: description 32000ms infinite -2000ms ease;
Expand Down Expand Up @@ -342,4 +348,4 @@ li {
}
*:focus {
outline: none;
}
}
10 changes: 6 additions & 4 deletions mysite/blog/templates/blog/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,18 @@
{% endfor %}
{% endif %}
{% block content %}

{% endblock %}
</div>
<div class="col-md-4">
<div class="content-section">
<h3>Our Sidebar</h3>

{% block contentr %}

{% endblock %}

<p class='text-muted'>You can put any information here you'd like.
<ul class="list-group">
<li class="list-group-item list-group-item-light">Latest Posts</li>
<li class="list-group-item list-group-item-light">Announcements</li>
<li class="list-group-item list-group-item-light">Calendars</li>
<li class="list-group-item list-group-item-light">etc</li>
Expand All @@ -98,4 +101,3 @@ <h3>Our Sidebar</h3>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
</body>
</html>

15 changes: 14 additions & 1 deletion mysite/blog/templates/blog/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,17 @@ <h2><a class="article-title" href="{% url 'post-detail' post.id %}">{{ post.titl
<p class="article-content">{{ post.content }}</p>
</div>
</article>
{% endfor %} {% endblock%}
{% endfor %} {% endblock%}

{% block contentr %}
<div class="content-section">
<ul>
<h4>Latest Posts</h4>
{% for post in postsl %}

<li><a href="{% url 'post-detail' post.id %}">{{ post.title }}</a></li>
<small>{{ post.date_posted }}</small>

{% endfor %}
</div>
{% endblock%}
4 changes: 3 additions & 1 deletion mysite/blog/templates/blog/post_detail.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

{% extends "blog/base.html" %}
{% block content %}
<article class="media content-section">
Expand All @@ -17,4 +18,5 @@ <h2 class="article-title">{{ object.title }}</h2>
<p class="article-content">{{ object.content }}</p>
</div>
</article>
{% endblock content %}
{% endblock content %}

1 change: 1 addition & 0 deletions mysite/blog/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
path("post/<int:pk>/update/", PostUpdateView.as_view(), name="post-update"),
path("post/<int:pk>/delete/", PostDeleteView.as_view(), name="post-delete"),
path("post_create/", post_create, name="post_create"),

]
14 changes: 10 additions & 4 deletions mysite/blog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
from .models import Post
from django.views.generic import ListView
from django.contrib.auth.models import User
from django.db.models import Q
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin

# Create your views here.
from django.views.generic import DetailView, UpdateView, DeleteView

from django.contrib import messages
from django.contrib.auth.decorators import login_required
from .forms import PostForm
from django.db.models import Q

from django.shortcuts import render, get_object_or_404
# Create your views here.

def home(request):
Expand All @@ -34,6 +38,7 @@ def home(request):
'mostliked2':mostliked2,
'mostliked3':mostliked3,
'mostliked4':mostliked4,
'postsl': Post.objects.all().order_by('-date_posted')[:5]
}
return render(request,'blog/home.html', context)

Expand All @@ -42,15 +47,15 @@ def about(request):

def Profileview(request,name):
user =User.objects.get(username=name)
flag = (request.user==Post.author)
flag = (request.user==post.author)
context={
'user':user, 'flag':flag
}
if request.user!=user:
return render(request,'user/profile.html', context)
else:
context={
'posts': Post.objects.all(),'flag':flag
'posts': post.objects.all(),'flag':flag
}
return render(request,'blog/home.html',context)
class PostDetailView(DetailView):
Expand Down Expand Up @@ -92,4 +97,5 @@ def post_create(request):
context ={
"form": form
}
return render(request, "blog/post_create.html", context)
return render(request, "blog/post_create.html", context)