zhannamatuzak / lizard-my-pet

CI PP4
1 stars 1 forks source link

Lizard Is My Pet

Introduction & Project's Goal

This Django project functions as a specialized blog designed for individuals contemplating the idea of adopting a 🦎 lizard as a pet. It caters not only to those in search of essential information for decision-making but also to experienced lizard owners eager to share their firsthand experiences. Owners are invited to share insights into various aspects of daily life with their lizard, including preferred food choices, potential size and growth, lifespan, and even unique names for these captivating pets. The administrator provides visitors with posts about various lizard species, offering a comprehensive overview to assist them in making informed decisions. Simultaneously, visitors who have a lizard as a pet can actively contribute by sharing their own experiences in the experience (comments) section below each post. Reading about the experiences of others serves as a valuable resource for decision-making too. Only registered users have access to submit their experiences across all posts and to like the posts.

Desktop mockup:

responsive mockup desktop

Link to live site


Agile Strategy

This project follows the agile approach, encompassing the entire development lifecycle from initial planning to final implementation. To illustrate the process, I established a GitHub project and employed the Kanban board method provided. This method facilitated the breakdown of project elements into user stories and manageable tasks.

Ensuring the successful implementation of user stories is fundamental to this project. It involves testing to confirm that the delivered features align with specified criteria.

To access comprehensive details, including acceptance criteria and tasks for each user story, please refer to the linked project above. Additionally, each story is categorized with a labeled indicator, signifying its importance to the overall functionality and acceptability of the site. The user stories are closely aligned with their respective epics (Full User Managment, Manage posts, Create, Editing and Deleting Experiences), and three epics are organized under the milestone "Create the full Backend and Frontend". For a detailed view of user stories, please refer to the 'Testing.md' document."

Scope

The scope of this project encompasses a set of features designed to create an engaging and interactive blog centered around lizards (posts).

Design Choices

Colors

I used this palette to style the blog:

To see the color palette, click hier

Typography

Icons

icons post list

edit and delete buttons

Animations: links & buttons

buttons

Responsiveness

Wireframes

The initial wireframes in canva are an overly simplified version of the finished product and merely served the purpose of listing most of the site's essential features.

Home Page

home page wireframe

Detailed view of a Post

detailed view of the post

Not all features and functions are covered by these wto drafts.

About all existing features read below ↓↓↓


Features

Navigation

Site visitor:

navbar icons

Registered user:

navbar icons signedup

Hamburger menu:

navbar icons

Lizard List

lizard list page

Lizard Detail

lizard detail section

Likes

lizard detail section

lizard detail section

Shared experiences (Comments)

Register (sign up)

signup form

Login/Logout

signin form

log out

To learn more details about User Managment, please click here.

Footer

Error 404/403/

Features for Future Development


Database Design

The Database consists of three models:

The database model diagram was designed using Lucidchart.

Data model

USER MODEL

In this project, Django's built-in application, contrib.auth, was utilized to manage user authentication and authorization. This application provides a comprehensive infrastructure encompassing models, views, and forms. Its functionalities extend to handling user authentication, password reset mechanisms, permissions, and more.

User model

Custom Models:

🦎LIZARD MODEL

The Lizard model was customised according to the data needed for the "Lizard is my pet" blog concept.

key Database Key Type Validation
title CharField max_length=100, unique=True
slug SlugField max_length=100, unique=True
FK author User model User, on_delete=models.CASCADE
description TextField validators=[RegexValidator(regex=r'^[A-Za-z0-9\s.,!?]*$')]
image CloudinaryField default='default'
created_on DateField uto_now_add=True
max_size IntegerField validators=[MinValueValidator(1)]
lifespan IntegerField validators=[MinValueValidator(1)]
price_from IntegerField validators=[MinValueValidator(1)]
price_to User Model validators=[MinValueValidator(1)]
diet CharField max_length=50, choices=DIET, default="0"
diet_list TextField validators=[RegexValidator(regex=r'^[A-Za-z0-9\s.,!?]*$')]
status IntegerField choices=STATUS, default=0

âť— I had to change the "diet" variable field from Integer to CharField. To read more details about the *ISSUE,* see user issue 12.

Variables for choice:

DIET = [
        ("0", "Not defined"),
        ("1", "Omnivorous"),
        ("2", "Herbivorous"),
        ("3", "Insectivorous"),
    ]

Methods:

  class Meta:
        ordering = ['-created_on']

    def __str__(self):
        return self.title

    def number_of_likes(self):
        return self.likes.count()

EXPERIENCE MODEL

key Database Key Type Validation
FK post Lizard Model Lizard, on_delete=models.CASCADE
FK user User Model User, on_delete=models.CASCADE
pet_name CharField default="What's your pet name?", max_length=80, validators=[RegexValidator(regex=r'^[a-zA-Z]*$',)]
size IntegerField default=0, validators=[MinValueValidator(1), MaxValueValidator(100)]
body TextField default="Here can be your experience...", max_length=800
created_on DateField uto_now_add=True
likes ManyToManyField User, related_name='post_like', blank=True

Methods:

class Meta:
        ordering = ['created_on']

    def __str__(self):
        return f"Experience {self.body} by {self.user}, petname: {self.pet_name}, size: {self.size}cm"

Testing

Please refer to the TESTING.md file for all testing performed.

Technologies Used

Work Environments and Hosting

Python Libraries

Django Libraries

Database


Local deployment

Note:

Create a local copy of the GitHub repository by following one of the two processes below:


Deployment

This project was deployed using Heroku, Cloudinary, ElephantSQL and Whitenoise.

using Gitpod, you can click below to create your own workspace using this repository.

Installing libraries

pip3 install django gunicorn
pip 3 install dj_database_url pyscopg2
pip3 install dj3-cloudinary-storage
pip3 install whitenoise

Getting set up

pip3 freeze --local > requirements.txt
django-admin startproject lizardmypet .
python3 manage.py startapp blog
python3 manage.py migrate
python3 manage.py runserver

If everything works, it will appear this:

Django: The install worked successfully!

Creating the Heroku App

Heroku: Automatic Deployment

pip3 install gunicorn~=20.1
pip3 freeze --local > requirements.txt
web: gunicorn codestar.wsgi

Hint: Note there is a space after the colon. Hint: The Procfile has no file extension.

Create PostgreSQL database using ElephantSQL

This is necessary to create a database that can be accessed by Heroku. The database provided by Django can not be accessed by the deployed Heroku app.

New Instance ElephantSQL

Plan and Name ElephantSQL

Select region and data center

Details section

 python manage.py createsuperuser

Hiding sensitive information

os.environ["DATABASE_URL"]="<copiedURL>"
os.environ["SECRET_KEY"]="mysecretkey"

Hier I have generated the key: Django Secret Key Generator

Update Settings

SECRET_KEY = os.environ.get('SECRET_KEY')

Connecting Heroku to Database

Connect to Cloudinary

Cloudinary API

Allow Heroku as host

No error Heroku

Final Deployment

âť— Fixed Bugs

Credits

Code

  1. MinValueValidator, MaxValueValidator - MinValueValidator was used to help validate the max_size, lifespan, proce_from, price_to fields in the LizardModel in Models.py file, to ensure that the values of max_size, lifespan, proce_from, price_to are greater than or equal to 1.
  2. Django in 20 minutes - a brief video about the essential requirements for creating a simple Django project.
  3. Two projects that inspired me: recipe and steam & leaf blog.
  4. The Code Institute 'I Think, Therefore I Blog' walkthrough project assisted and guided in the setup and basic structure of this project.

Content, Media, and Styling

Acknowledgements

Back to the beginning