You are on page 1of 43

CERTIFICATE OF ORIGINALITY

I hereby declare that the work which is being presented in this projects work entitled

“Survivors Tale” in partial fulfillment of the requirement for the award of the degree of

Bachelor of Computer Application at Hi-Tech Institute of Engineering & Technology,

Ghaziabad is and authentic record of our own work carried out during the period Feb-

2021 to May-201 under the supervision and guidance of Ms. Chhaya Yadav.

I have not submitted the matter embodied in this project work anywhere for the

award of any degree or diploma.

Place :

Date: Signature of candidates:


ACKNOWLEDGEMENT

With a deep sense of gratitute, I wish to express our sincere thanks to our supervisor, Ms..

Chhaya Yadav, for her/his help in planning and executing and executing the work in time. The

confidence and dyanmism with which she/he guided the work requires no elaboration. Her

company and assurance at the time of crisis would be remembered lifelong. Her valualble

suggestions as final words during the course of work are greatly acknowledged. What I know

today about the process of project, I learned from Ms. Chhaya Yadav.

Our sincere thanks to Ms. Chhaya Yadav (project coordinator) for providing me constant

encouraging. Our special thanks to Dr. A.K. Maheshwari (Director) and Amit Saxena (Head of

department of Bachelor of Computer Application) for extending timely help in carrying out our

important pieces of work. The cooperation I received from other faculty members of our

department is grateful acknowledged. I will be failling in our duty if I do not mention the

laboratory staff and adminitrative staff of this department for their timely help.

Finally, I would like to thank all whose direct and indirect support helped us in completing our

project in time.

Date: Signature:
SYSTEM ANALYSIS

System analysis is a way of studying a system with an eye on solving it’s problem using

computer. It is the most essential part of the development of the project of a system

analysis. System analysis consist of system element, process and technology. To analysis

a system, has to study the system in details.

The analyst has to understand the funtioning and concept of system in detail, before

designing the appropriate computer based system that will meet all the requirement of

the exiting system. The system has to carry out the customary approach too use the

computer for solving problems.

The above steps constitute the logical framework for the system analysis.

After the preliminary investigation and feasibility study, the scope of the defined and

comparable items are set forth and hence detailed investigation in executed. This allows

the system analyst to comprehend the full scope of the project. Soon after

implementation of the newly developed system, followed by the training of the user, the

system analyst in included.

Preliminary investigation:-

A request to receive assitance from information system can be made of many

reasons, but in a case of manager, employee, system specialist initiated the request.

When that request is made, the first system activity preliminary investigation begins.
FEASIBILITY STUDY

Feasibiliy study is to deteminine the possibility or probability of improving the exiting system or
developing a totally new system. Feasibility study is systematic and through study of the
existing system and an attempt to trace out the disadvatage of the existing system.

Once management accepts the study proposals, It will lead to and investigation of the
existing system or problem area. This invesgation is conducted in close collaboration with user
management and insufficient depth to establish in broad terms the technical, operational, and
economical feasibility of the proposal.

The purpose of this chat is to communicate efficiently with different users in a local are network
and exhange data between them. The feasibility of this project depends upon a number of factors
such as time, cost and technology etc.

Need for feasibility study:-

The feasibility study is needed for following things.

➢ Answer the question wherther a new system is intalled or not?

➢ Determine the potentail of exiting system.

➢ Improve the exiting system.

➢ Know what should be embedded in new system.

➢ Definne the problems and objective involved.

➢ Avoid costly and at later stage when system is implement.

➢ Avoid crash implementaion new system


The fesibility study is divied in to three parts:-

➢ Technical feasibily

➢ Operational feasibility

➢ Economical feasibility

Technical feasibility

Technical feasibily centers on the existing manal system of the test management

process and to what extent is can support the system.

According to feasibility system analysis the technical feasibility of the system is

analyzed and the technical requirement such as software facilites, procedures, inputs are

identified. It is also one of the important phase of the system development activities.

The system offers the greater levels of user friendliness combined with greater

processing speed. Therefore cost of the maintenace can be reduced, Since processing

speed is very high and the work is reduced in the maintenance point of view,

management conviced that the project is feasible.


Economical feasibility

Economic analysis is most frequently used for evaluation of the effectiveness of

the system. More commonly knows as cost/benefit analysis the procedure is to determine

the benefit and saving that are expected from a system and compare them with costs,

decisions is made to design and implement the system.

This part of feasibility study gives the top management the economic justification for the

new system. This is an important input to the management the management, because

very often the top management does not like to get confounded by the various

technicalities that bound to be associated with a project of this kind. A simple economic

analysis that gives the actual comparison of costs and benefits is much more meaningful

in such cases.

In the system, the organization is most satisfied by economic feasibility. Because, if the

organization implements this system, it need not require any additional hardware

resources as well as it will be saving lot of time.


Operational feasibility

Operational feasibility is the ability to utilize, support and perform the


necessary tasks of a system or program. It includes everyone who creates, operates
or uses the system. To be operationally feasible, the system must fulfil a need
required by the business.

Programs that reduce costs without reducing the quality of a product are an
example of operational feasibility. Studies are performed to make sure that
programs can be initiated in the current production facility, without the need for
more equipment or staff. If there is a need for more room, machinery or personnel,
the system needs to make an improvement in the way the product is perceived by
consumers. This allows the added expense to manufacture the product because of
the anticipated increase in sales and revenue. Economic feasibility is one portion
of operational feasibility. Everyone involved in the manufacturing and use of the
system, product or program needs to understand it and be able to use it in the
manner it was designed to be used. Feasibility studies are done not only in the
private business sector, but by all governmental organizations. If the changes made
to a product or program are not understood by the end users, it is not considered
feasible.
INTRODUCTION

Django is one of the best web framework that we have in modern


times it works on python (programming language). Django is fast,
convenient, and professional in handling project files. Allows us to
develop backend facilities for our websites and this project consist one
such website that used Django in order to implement backend as well
as integrate it with frontend files.
Django follows model-template-view architectural pattern.
This framework came into market with the goal to ease the creation
of complex, and data driver websites.
Django allows large number of python libraries to be
integrated with the web application.
IT takes security seriously and help developers avoid many
common mistakes.
This website lets its users to share their life’s traumatic
experiences with the world so that someone in the same situation
can find out what to do and what not in such situations.
The stories can be divided into large number of categories such as how
someone recovered from coronavirus, how someone handled
domestic abuse, how someone fought against poverty, etc.
This website consists all the features that a modern dynamic website
should have in order to make it easy to use.
INDEX
1. Database………………………....…………………..……….. 1
2. Model View Template…………………………...…................ 1
3. Register Users………………………………………......…….. 1
4. Commenting System…………………………………....…...... 1
5. User Login System……………………………………............. 2
6. CRUD Operations…………………………………….......…... 2
7. Password Reset………………………………….………..…… 2
8. QR-Code………………………………………….………........ 2
9. Requirements……………………………………….…...…….. 2
10. Data from USER App……………………………..……....... 3
a. view.py from USER App………………………..……..... 3
b. models.py from USER App………………………..…..... 6
c. forms.py from USER App…………………………..…… 8
d. templates/user/SignUp.html file……………………......... 9
11. Data from BLOG App……………………………………..... 11
a. Views.py from BLOG App……………………………… 11
b. models.py from BLOG App………………………..….... 15
c. blog/templates/base.html…………………....................... 17
d. blog/templates/blog/home.html……………………......... 21
e. blog/templates/blog/home_category.html………...…..… 26
f. blog/templates/blog/user_stories.html…………..….....… 30
12. Bibliography………………………………………..……...... 34
Database
➢ MySQL
MySQL is used to store user’s data in the project.
MySQL is an open- source relational database
management system.

Model-View-Template
➢ Architecture
Django is based on MVT (Model-View-
Template) architecture. MVT is a software design
pattern for developing a web application. View is the user
interface that you want to see when you render a website.

Register Users
➢ User’s Registration in database
A User model can be created in models.py file and can be
migrated to the database to create an exact model in
database. Later can be used to save data of users.

Commenting System
➢ Django-comments-xtd
A python library called django-comments-xtd it is and
extended version of Django-comments library is used to
implement commenting system in this website. The
commenting system contains like, dislikes, reply, and
flagging features.

1
User Login System

➢ Login System
A Getting the data from the user and comparing it against
the data that is stored in database and allowing user to
access the feature which required sign in by user.

CRUD Operations

➢ CRUD facility
CRUD refers to create, read, update, and delete. A user is
allowed to perform all these operations on their posts and
on their profile data.

Password Reset
➢ Password reset facility
A user can send an automatically generated token with
link to his/her email address to reset their password in
case they forget their password.

QR-Code
➢ QR-Code for profile
Every user is provided with a separate QR-Code which
he/she can share with anyone to give they the direct link
to their profile on of this website.

Requirements

➢ Basic requirements to access the website


o Active internet connection.
o Computer or a mobile.
o Latest Web browsers with enabled HTML, CSS, and JS.
2
Data from USER App

Views.py file of USER App

from django.shortcuts import render, redirect, get_object_or_404

from django.contrib import messages

from blog.models import Story

from django.contrib.auth.models import User

from .forms import UserRegisterForm, UserUpdateForm, ProfileUpdateForm

from django.contrib.auth.decorators import login_required

# Create your views here.

def signUp(request):

if request.method == 'POST':

form = UserRegisterForm(request.POST)

if form.is_valid():

form.save()

username = form.cleaned_data.get('username')

messages.success(request, f'Your account has been created {username}! You are now

able to log in')

3
return redirect('login')

else:

form = UserRegisterForm()

return render(request, 'user/signUp.html', {'form': form})

def profile(request, username):

if request.user.is_authenticated:

print("auth")

if request.method == 'POST':

u_form = UserUpdateForm(request.POST, instance=request.user)

p_form = ProfileUpdateForm(request.POST, request.FILES,

instance=request.user.profile)

if u_form.is_valid() and p_form.is_valid():

u_form.save()

p_form.save()

print('yes valid')

messages.success(request, f'Your account has been updated!')

return redirect('profile', username=username)

4
else:

u_form = UserUpdateForm(instance=request.user)

p_form = ProfileUpdateForm(instance=request.user.profile)

context = {

'u_form': u_form,

'p_form': p_form

else:

user = User.objects.filter(username=username).first()

print('Not Auth')

context = {

'username': user.username,

'user_email': user.email,

'actual_qr': 'www.survivorsblog.com/profile/' + username

return render(request, 'user/profile.html', context)

5
models.py file of USER App

from django.db import models

from django.contrib.auth.models import User

from PIL import Image

class Profile(models.Model):

user = models.OneToOneField(User, on_delete=models.CASCADE)

image = models.ImageField(default='default.jpg', upload_to='profile_pics')

def __str__(self):

return f'{self.user.username} profile'

def save(self, **kwargs):

super().save()

img = Image.open(self.image.path)

if img.height > 300 or img.width > 300:

output_size = (300, 300)

6
img.thumbnail(output_size)

img.save(self.image.path)

7
forms.py file of USER App

from django import forms

from django.contrib.auth.forms import UserCreationForm

from django.contrib.auth.models import User

from .models import Profile

class UserRegisterForm(UserCreationForm):

email = forms.EmailField()

class Meta:

model = User

fields = ['username', 'email', 'password1', 'password2']

class UserUpdateForm(forms.ModelForm):

class Meta:

model = User

fields = ['username', 'email']

class ProfileUpdateForm(forms.ModelForm):

class Meta:

model = Profile

fields = ['image']

8
templates/user/signUp.html file

{% extends "blog/base.html" %}

{% load crispy_forms_tags %}

{% block content %}

<section class="text-gray-500 bg-gray-900 body-font">

<div class="container px-5 py-24 mx-auto flex flex-wrap items-center">

<div class="lg:w-3/6 md:w-1/2 bg-gray-800 rounded-lg p-8 flex flex-col md:ml-auto w-

full mt-10 md:mt-0"

style="margin: auto;">

<form method="POST" class="m-2" style="background-color: rgb(45, 55, 72);">

{% csrf_token %}

<fieldset class="form-group" style="margin:25px;">

<legend class="border-bottom mb-4">Join Today</legend>

{{ form|crispy }}

</fieldset>

<div class="form-group mt-1">

<button class="btn text-white border-0 py-2 px-8 focus:outline-none h rounded

text-lg ml-4 custom_login_css_btn" type="submit">Sing Up</button>

</div>

9
<div class="border-top pt-3 " style="margin:19px;">

<small class="text-muted ">

Already have have an account ? <a href="{% url 'login' %}">Log in</a>

</small>

</div>

</form>

</div>

</div>

</section>

{% endblock content %}

10
Data from BLOG App

views.py file of USER App

d from django.shortcuts import render, get_object_or_404

from django.views.generic import ListView, DetailView, CreateView, UpdateView,

DeleteView

from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin

from qr_code.qrcode.utils import ContactDetail

from datetime import date

from .models import Story

from django.contrib.auth.models import User

from django.http import HttpResponse, request

def about(request):

return render(request, 'blog/about.html', {'title': 'about'})

class StoryListView(ListView):

model = Story

template_name = 'blog/home.html'

11
context_object_name = 'stories'

ordering = ['date_posted']

paginate_by = 5

class CategoryStoryListView(ListView):

model = Story

template_name = 'blog/home_category.html'

context_object_name = 'stories'

ordering = ['date_posted']

paginate_by = 5

def get_queryset(self):

return Story.objects.filter(category=self.kwargs.get('category')).order_by('-

date_posted')

class UserStoryListView(ListView):

model = Story

template_name = 'blog/user_stories.html'

context_object_name = 'stories'

ordering = ['date_posted']

12
paginate_by = 3

def get_queryset(self):

user = get_object_or_404(User, username=self.kwargs.get('username'))

return Story.objects.filter(author=user).order_by('-date_posted')

class StoryDetailView(DetailView):

model = Story

class StoryCreateView(LoginRequiredMixin, CreateView):

model = Story

fields = ['title', 'category', 'story']

def form_valid(self, form):

form.instance.author = self.request.user

return super().form_valid(form)

class StoryUpdateView(LoginRequiredMixin, UserPassesTestMixin, UpdateView):

model = Story

fields = ['title', 'story']

def form_valid(self, form):

13
form.instance.author = self.request.user

return super().form_valid(form)

def test_func(self):

story = self.get_object()

if self.request.user == story.author:

return True

return False

class StoryDeleteView(LoginRequiredMixin, UserPassesTestMixin, DeleteView):

model = Story

success_url = '/'

def test_func(self):

story = self.get_object()

if self.request.user == story.author:

return True

return False

14
models.py file of USER App

d from django.db import models

from django.contrib.auth.models import User

from django.urls import reverse

from django_comments_xtd.moderation import moderator, SpamModerator

from blog.badwords import badwords

# Create your models here.

SURVIVORS_CHOICES = (

("COVID-19", "COVID-19"),

("DOMESTIC VIOLENCE", "DOMESTIC VIOLENCE"),

("POVERTY", "POVERTY"),

("UNEMPLOYMENT", "UNEMPLOYMENT"),

("ILLITERACY", "ILLITERACY"),

15
class Story(models.Model):

title = models.CharField(max_length=100)

category = models.CharField(max_length=35, choices=SURVIVORS_CHOICES,

default="COVID-19")

story = models.TextField()

date_posted = models.DateField(auto_now_add=True)

author = models.ForeignKey(User, on_delete=models.CASCADE)

def __str__(self):

return self.title

def get_absolute_url(self):

return reverse('story-detail', kwargs={'pk': self.pk})

class StoryCommentModerator(SpamModerator):

email_notification = False

auto_moderate_field = 'date_posted'

moderate_after = 365

removal_suggestion_notification = True

moderator.register(Story, StoryCommentModerator)

16
templates/blog/base.html file

{% load static %}

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="stylesheet"

href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"

integrity="sha384-

Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"

crossorigin="anonymous">

<link href="https://cdn.jsdelivr.net/npm/tailwindcss@0.7.4/dist/tailwind.min.css"

rel="stylesheet">

<link href="https://cdn.jsdelivr.net/npm/tailwindcss@0.7.4/dist/preflight.min.css"

rel="stylesheet">

<link rel="stylesheet" type="text/css" href="{% static 'blog/main.css' %}">

<link rel="stylesheet" type="text/css" href="{% static 'blog/main_custom.css' %}">

{% if title %}

<title>Survivors blog-{{title}}</title>

17
{% else %}

<title> survivors blog</title>

{% endif %}

</head>

<body>

<!--<header class="site-header">-->

<nav class="navbar navbar-expand-lg navbar-dark bg-dark">

<a class="navbar-brand" href="#">Navbar</a>

<button class="navbar-toggler" type="button" data-toggle="collapse" data-

target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle

navigation">

<span class="navbar-toggler-icon"></span>

</button>

<div class="collapse navbar-collapse" id="navbarNav">

<ul class="navbar-nav">

<li class="nav-item active">

<a class="nav-link" href="{% url 'blog-index' %}">Home <span class="sr-

only">(current)</span></a>

</li>

18
<li class="nav-item">

<a class="nav-link" href="{% url 'blog-about' %}">about</a>

</li>

{% if user.is_authenticated %}

<li class="nav-item">

<a class="nav-link" href="{% url 'logout' %}">logout</a>

</li>

<li class="nav-item">

<a class="nav-link" href="{% url 'user-story' %}">create story</a>

</li>

{% else %}

<li class="nav-item">

<a class="nav-link" href="{% url 'login' %}">login</a>

</li>

<li class="nav-item">

<a class="nav-link" href="{% url 'signUp' %}">Sing Up</a>

</li>

{% endif %}

</ul>

19
</div>

</nav>

<!-- </header>-->

{% load qr_code %}

{% block content %}

{% endblock %}

<script src="https://kit.fontawesome.com/ce819f3921.js"

crossorigin="anonymous"></script>

<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-

J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n"

crossorigin="anonymous"></script>

<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"

integrity="sha384-

Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"

crossorigin="anonymous"></script>

<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"

integrity="sha384-

wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"

crossorigin="anonymous"></script>

</body>

</html>

20
blog/templates/blog/home.html file

{% extends 'blog/base.html' %}

{% load comments %}

{% block content %}

<form>

<div class="dropdown">

<button class="btn btn-secondary dropdown-toggle" type="button"

id="dropdownMenuButton" name="dropdown" data-toggle="dropdown" aria-

haspopup="true" aria-expanded="false">

Category

</button>

<div class="dropdown-menu" aria-labelledby="Category">

<a class="dropdown-item" href="{% url 'blog-category' 'COVID-19' %}">COVID-19</a>

<a class="dropdown-item" href="{% url 'blog-category' 'DOMESTIC VIOLENCE'

%}">DOMESTIC VIOLENCE</a>

<a class="dropdown-item" href="{% url 'blog-category' 'POVERTY' %}">POVERTY</a>

<a class="dropdown-item" href="{% url 'blog-category' 'UNEMPLOYMENT'

%}">UNEMPLOYMENT</a>

<a class="dropdown-item" href="{% url 'blog-category' 'ILLITERACY' %}">ILLITERACY</a>

21
</div>

</div>

</form>

{% for stori in stories %}

<section class="text-gray-500 bg-gray-900 body-font overflow-hidden">

<div class="container px-5 py-24 mx-auto">

<div class="-my-8">

<div class="py-8 flex flex-wrap md:flex-no-wrap">

<img class="rounded-circle article-img" src="{{ stori.author.profile.image.url }}">

<div class="md:w-64 md:mb-0 mb-6 flex-shrink-0 flex flex-col">

<span class="tracking-widest font-medium title-font text-white" ><a class="ml-1 mt-

1" href="{% url 'user-stories' stori.author.username %}">{{ stori.author }}</a></span>

<span class="tracking-widest font-medium title-font text-white">{{ stori.category

}}</span>

</div>

<div class="md:flex-grow">

22
<span class="mt-1 text-gray-600 text-sm">{{ stori.date_posted }}</span>

<h2 class="text-2xl font-medium text-white title-font mb-2"><a href="{% url 'story-

detail' stori.id %}">{{ stori.title }}</a></h2>

{% if post.content|length > 100 %}

<p class="leading-relaxed content-color">{{ stori.story|truncatechars:100 }}...</p>

{% else %}

<p class="leading-relaxed content-color">{{ stori.story }}</p>

{% endif %}

<a class="text-indigo-500 inline-flex items-center mt-4 " ><a href="{% url 'story-

detail' stori.id %}">Learn More</a>

</a>

</div>

</div>

</div>

</div>

</section>

<hr style="

/* color: white; */

border-bottom-width: thin;

23
">

{% endfor %}

{% if is_paginated %}

{% if page_obj.has_previous %}

<a class="btn mb-4 mt-4 ml-2" href="?page=1">First</a>

<a class="btn mb-4 mt-4 ml-2" href="?page={{ page_obj.previous_page_number

}}">Previous</a>

{% endif %}

{% for num in page_obj.paginator.page_range %}

{% if page_obj.number == num %}

<a class="btn btn-custom mb-4 mt-4 ml-10" href="?page={{ num }}">{{ num }}</a>

{% elif num > page_obj.number|add:'-3' and num < page_obj.number|add:'3' %}

<a class="btn mb-4 mt-4 ml-2" href="?page={{ num }}">{{ num }}</a>

{% endif %}

{% endfor %}

{% if page_obj.has_next %}

<a class="btn mb-4 mt-4 ml-2" href="?page={{ page_obj.next_page_number

}}">Next</a>

24
<a class="btn mb-4 mt-4 ml-2" href="?page={{ page_obj.paginator.num_pages

}}">Last</a>

{% endif %}

{% endif %}

{% endblock %}

25
blog/templates/blog/home_category.html file

{% extends 'blog/base.html' %}

{% block content %}

<form>

<div class="dropdown">

<button class="btn btn-secondary dropdown-toggle" type="button"

id="dropdownMenuButton" name="dropdown" data-toggle="dropdown" aria-

haspopup="true" aria-expanded="false">

Category

</button>

<div class="dropdown-menu" aria-labelledby="Category">

<a class="dropdown-item" href="{% url 'blog-category' 'COVID-19' %}">COVID-19</a>

<a class="dropdown-item" href="{% url 'blog-category' 'DOMESTIC VIOLENCE'

%}">DOMESTIC VIOLENCE</a>

<a class="dropdown-item" href="{% url 'blog-category' 'POVERTY' %}">POVERTY</a>

<a class="dropdown-item" href="{% url 'blog-category' 'UNEMPLOYMENT'

%}">UNEMPLOYMENT</a>

<a class="dropdown-item" href="{% url 'blog-category' 'ILLITERACY' %}">ILLITERACY</a>

</div>

26
</div>

</form>

{% for stori in stories %}

<section class="text-gray-500 bg-gray-900 body-font overflow-hidden">

<div class="container px-5 py-24 mx-auto">

<div class="-my-8">

<div class="py-8 flex flex-wrap md:flex-no-wrap">

<img class="rounded-circle article-img" src="{{ stori.author.profile.image.url }}">

<div class="md:w-64 md:mb-0 mb-6 flex-shrink-0 flex flex-col">

<span class="tracking-widest font-medium title-font text-white" ><a class="ml-1 mt-

1" href="{% url 'user-stories' stori.author.username %}">{{ stori.author }}</a></span>

<span class="tracking-widest font-medium title-font text-white">{{ stori.category

}}</span>

</div>

<div class="md:flex-grow">

<span class="mt-1 text-gray-600 text-sm">{{ stori.date_posted }}</span>

<h2 class="text-2xl font-medium text-white title-font mb-2"><a href="{% url 'story-

detail' stori.id %}">{{ stori.title }}</a></h2>

27
{% if stori.story|length > 100 %}

<p class="leading-relaxed content-color">{{ stori.story|truncatechars:100 }}...</p>

{% else %}

<p class="leading-relaxed content-color">{{ stori.story }}</p>

{% endif %}

<a class="text-indigo-500 inline-flex items-center mt-4 " ><a href="{% url 'story-

detail' stori.id %}">Learn More</a>

</a>

</div>

</div>

</div>

</div>

</section>

<hr style="

{% endfor %}

{% if is_paginated %}

{% if page_obj.has_previous %}

<a class="btn mb-4 mt-4 ml-2" href="?page=1">First</a>

28
<a class="btn mb-4 mt-4 ml-2" href="?page={{ page_obj.previous_page_number

}}">Previous</a>

{% endif %}

{% for num in page_obj.paginator.page_range %}

{% if page_obj.number == num %}

<a class="btn btn-custom mb-4 mt-4 ml-10" href="?page={{ num }}">{{ num }}</a>

{% elif num > page_obj.number|add:'-3' and num < page_obj.number|add:'3' %}

<a class="btn mb-4 mt-4 ml-2" href="?page={{ num }}">{{ num }}</a>

{% endif %}

{% endfor %}

{% if page_obj.has_next %}

<a class="btn mb-4 mt-4 ml-2" href="?page={{ page_obj.next_page_number

}}">Next</a>

<a class="btn mb-4 mt-4 ml-2" href="?page={{ page_obj.paginator.num_pages

}}">Last</a>

{% endif %}

{% endif %}

{% endblock %}

29
blog/templates/blog/user_stories.html file

{% extends 'blog/base.html' %}

{% block content %}

<h1>Stories by {{ view.kwargs.username }} ({{ page_obj.paginator.count }})</h1>

{% for stori in stories %}

<section class="text-gray-500 bg-gray-900 body-font overflow-hidden">

<div class="container px-5 py-24 mx-auto">

<div class="-my-8">

<div class="py-8 flex flex-wrap md:flex-no-wrap">

<img class="rounded-circle article-img" src="{{ stori.author.profile.image.url }}">

<div class="md:w-64 md:mb-0 mb-6 flex-shrink-0 flex flex-col">

<span class="tracking-widest font-medium title-font text-white" ><a class="ml-1 mt-

1" href="{% url 'user-stories' stori.author.username %}">{{ stori.author }}</a></span>

<span class="tracking-widest font-medium title-font text-white">{{ stori.category

}}</span>

</div>

<div class="md:flex-grow">

30
<span class="mt-1 text-gray-600 text-sm">{{ stori.date_posted }}</span>

<h2 class="text-2xl font-medium text-white title-font mb-2"><a href="{% url 'story-

detail' stori.id %}">{{ stori.title }}</a></h2>

{% if stori.story|length > 100 %}

<p class="leading-relaxed content-color">{{ stori.story|truncatechars:100 }}...</p>

{% else %}

<p class="leading-relaxed content-color">{{ stori.story }}</p>

{% endif %}

<a class="text-indigo-500 inline-flex items-center mt-4 " ><a href="{% url 'story-

detail' stori.id %}">Learn More</a>

</a>

</div>

</div>

</div>

</div>

</section>

<hr style="

31
/* color: white; */

border-bottom-width: thin;

">

{% endfor %}

{% if is_paginated %}

{% if page_obj.has_previous %}

<a class="btn mb-4 mt-4 ml-2" href="?page=1">First</a>

<a class="btn mb-4 mt-4 ml-2" href="?page={{ page_obj.previous_page_number

}}">Previous</a>

{% endif %}

{% for num in page_obj.paginator.page_range %}

{% if page_obj.number == num %}

<a class="btn btn-custom mb-4 mt-4 ml-10" href="?page={{ num }}">{{ num }}</a>

{% elif num > page_obj.number|add:'-3' and num < page_obj.number|add:'3' %}

<a class="btn mb-4 mt-4 ml-2" href="?page={{ num }}">{{ num }}</a>

{% endif %}

{% endfor %}

{% if page_obj.has_next %}

32
<a class="btn mb-4 mt-4 ml-2" href="?page={{ page_obj.next_page_number

}}">Next</a>

<a class="btn mb-4 mt-4 ml-2" href="?page={{ page_obj.paginator.num_pages

}}">Last</a>

{% endif %}

{% endif %}

{% endblock %}

33
BIBLIOGRAPHY

Book referred :-

Internet references :-

1. YouTube/CoreySchafer

2. docs.djangoproject.com/

3. YouTube/ShaurabhSharma

4. docs.python.org/

34

You might also like