Skip to content

faozziyyah/django-blog-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

django-blog-app

full stack CRUD blog website built with HTML, Bulma CSS, and Django framework.
HTML5 Bulma Django

Table of contents

Overview

The challenge

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

Screenshot

Links

My process

Built with

  • HTML
  • Bulma - CSS framework
  • Django

What I learned

  • 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 %}

Useful resources

  • Django - Django makes it easier to build better web apps more quickly and with less code.
  • Bulma CSS - Django makes it easier to build better web apps more quickly and with less code.

Releases

No releases published

Packages

No packages published