Skip to content

egecam/RateMyCocktail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RateMyCocktail

A social platform to share and rate cocktail recipes made with Django 4.2.

Models

  • Recipe
    • user (ForeignKey from django.contrib.auth.models User model),
    • title (CharField),
    • ingredients (CharField),
    • body (CharField)

Contains a method: average_rating(self) which returns the average rating of the recipe object.

  • Rating
    • user (ForeignKey from django.contrib.auth.models User model),
    • recipe (ForeignKey) from Recipe model.
    • rating (IntegerField)

An interesting fact: We didn't create a model for "user". We just simply use the built-in Django User model which we import from the auth module.

Views

With a template

  • Home

Contains a random cocktail page which works with a third party API (CocktailDB) to fetch random cocktail data every single refresh.

  • Community

User-created cocktail data are being represented here. Users can rate listed recipes with the Rating function. Average rating score is shown right after the recipe.

  • New recipe

The view for creating a new recipe with Title, Ingredients and Description fields.

  • Register

The view where the user can create an account with a username and a password. Username must be unique and it is checked by;

if User.objects.filter(username = username).first():
    messages.error(request, "This username is already taken. Choose another one.")
    return render(request, 'register.html')

User model is imported from django.contrib.auth.models package and messages from django.contrib.

  • Login

User can login to an existing accout with a correct username-password pair.

Without a template

  • Logout

A simple logout view, works with the logout method from django.contrib.auth.

  • Delete

  • Rate

Templates

We use Django template language for forms and Bootstrap for styling.

  • Home
  • Community
  • New Recipe
  • Login
  • Register

Run Locally

Clone the project

  git clone https://github.com/egecam/RateMyCocktail.git

Go to the project directory

  cd RateMyCocktail

Create and activate the virtual environment

See: venv — Creation of virtual environments.

Install dependencies

  pip3 install django

Start the server

(First, locate to main directory which is the one with a file named manage.py)

  python manage.py runserver

For Mac users;

use python3 instead of python.

Deployment

To deploy this project run;

  python manage.py migrate
  python manage.py makemigrations Cocktails
  python manage.py migrate
  python manage.py runserver

for Mac users;

use python3 instead of python.

Authors

License

GPL-3

About

A cool cocktail platform.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published