full stack CRUD blog website built with HTML, Bulma CSS, and Django framework.
Users should be able to:
- Add a post.
- View each post.
- Add comments to the post and like a post.
- Follow and unfollow users.
- View post categories.
- Login as a user and log out.
- Update and delete posts.
- Search for posts.
- View the optimal layout for the site depending on their device's screen size
- Solution URL: (https://github.com/faozziyyah/django-blog-app)
- Live link: (not yet available)
- HTML
- Bulma - CSS framework
- Django
- Django authentication and authorization
- How to use the Django Admin
- pagination
- Adding Images
def like_post(request):
username = request.user.username
post_id = request.GET.get('post_id')
post = Post.objects.get(id=post_id)
like_filter = LikePost.objects.filter(post_id=post_id, username=username).first()
if like_filter == None:
new_like = LikePost.objects.create(post_id=post_id, username=username)
new_like.save()
post.no_of_likes = post.no_of_likes+1
post.save()
return redirect('index')
else:
like_filter.delete()
post.no_of_likes = post.no_of_likes-1
post.save()
return redirect('index')
<div id="loginform">
<h1 style="text-transform: uppercase; font-size: 25px; text-align: center; font-weight: bold; color: #46436d; margin-top: 1em;">Add Post </h1> <br />
{% if submitted %}
<h1 style="text-align:center; font-size: 20px; font-style:italic; margin-top: 1em;"> Your Post was submitted successfully!!!
<br /> Waiting For Approval !!!
</h1>
{% else %}
<form action="" method="POST" enctype="multipart/form-data" style="width: 80%; margin: auto;">
{% csrf_token %}
{{ form.as_p }} <br />
<input type="submit" value="Add Post" class="button is-link" />
</form>
</div>
{% endif %}