Skip to content

A django rest framework restaurant management system with 2 working apps utilizing a single database and one as to many ccommunication

Notifications You must be signed in to change notification settings

Ndhlovu1/django-crud-api-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Django Rest Framework(RestApi) Management System

A django rest framework restaurant management system

Built on an Ubuntu machine >= 18.04 - Commands will still run on windows(please read the wiki)

Visit the full installation instructions

Please visit the project wiki to properly configure the application or and to better understand the code

https://github.com/Ndhlovu1/django-crud-api-system/wiki

VSC Extensions

  1. SQLite Viewer by qwtel.com aka Florian Klampfer
  2. Install Git from https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
  3. Install Github Cli for your local machine https://cli.github.com/manual/installation

Project Setup

Installing and activating Environments
This project will be using pipenv to handle all our files and dependencies. If you don't have pipenv installed follow the steps below to install and configure it, ensure you also have pip installed
# If you don't have pip installed run the below command 
> sudo apt install python3-pip
> pip3 --version   

You should receive the version if everything went well

> pip3 install pipenv
> pipenv --version

follow the link to read more https://pipenv.pypa.io/en/latest/

Install django and the Virtual Environment

# Run the command below to install the code needed for django
> pipenv install django
# To activate the virtual environment
> pipenv shell
# To deactivate the virtual environment
> deactivate
You should see that now you will be in a virtual environment with the name of the containing folder you are in.

SIDE NOTE : VERY IMPORTANT DON'T SKIP THIS!!!!!

When you have more than one django projects setup and running with pipenv in visual studio code(vscode) either way always run through this step when creating a new django app
You may find that your virtual environment is reflecting an older project due to this
Solution : inside vscode press ctrl + shift + p the prompt below will appear , type/select interpreter

Screenshot from 2023-01-08 23-02-54

Solution : inside vscode then search for your virtual environment (it'll have the folder name you ran the commands in)

Screenshot from 2023-01-08 23-03-07

Result : inside vscode in the terminal, you'll see the environment is now the same as the one you selected

Screenshot from 2023-01-07 01-24-52

Continuing - Create the Project

django-admin startproject RestaurantProject

The code above will setup all the necessary files that you need to be able to run create the various applications. (Consider this the Heartbeat of your project, always make sure you know what's happening and where it is happening in these files.)

Continuing - Create the Apps

Navigate into the newly created "RestaurantProject" folder and run the abovestartapp command. The command allows you to setup your very own django application(You can view this as a section of the entire web application, i.e. the Comments Section)

python3 manage.py startapp usersApp

While in the same folder, run the above command to create your second app.

python3 manage.py startApp workersApp

The command install allows python and django to interpret the rest of your project as a Django Rest Framework

pipenv install djangorestframework

The settings.py file without the implemented changes

# go into the RestaurantProject/settings.py file 
# Look for :
# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

#then change it to add(text after space), be certain to not forget the , at the end and to remove the space

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    
    'usersApp',
    'workersApp',
    'rest_framework',
]

Start the server and see if it is running by typing the command below

Verify success project setup

#Ensure you are in the folder with the file manage.py
> python3 manage.py runserver

Type the code above to install and setup django as well as the virtual environment for you

The above shell command can be expected to add the load the below image, if yes then the entire setup was a success! Congrats!!!

django_successful_install

Files to be edited

  • Project level urls.py , as the name implies it is found in the RestaurantProject folder within the container folder (Read the Commit comments)
  • Screenshot from 2022-12-30 00-55-36

    Files to be created

  • App level urls.py , You will have to create this one as it isn't provided by default when creating an app with manage.py
  • Screenshot from 2022-12-30 00-51-00 Screenshot from 2022-12-30 00-50-52

  • serializers.py , this file must be created as it is needed to utilize the API's
  • Screenshot from 2022-12-30 00-50-46 Screenshot from 2022-12-30 00-50-40

    Projects Screenshots

    Images of the Project

    The Listed Menu - affected directly by our Api-End points, the web-page updates on a page refresh

    Screenshot from 2022-12-29 21-46-26

    The Create['POST'] and fetch['GET'] Api(s) - Adding information to the database and pulling the information

    Screenshot from 2022-12-29 21-42-11

    The Replace ['PUT'] and the Edit ['Patch'] are added into one button as we are utilizing the generics.RetrieveUpdateDestroyAPIView method

    Screenshot from 2022-12-29 21-42-38

    The full fetch ['GET'] API sharing the data available in our model or database table

    Screenshot from 2022-12-29 21-44-17

    The ['POST'] method available and ready to insert more information into the database

    Screenshot from 2022-12-29 21-44-21

    The database recording all the installed records in real-time

    Screenshot from 2022-12-29 23-04-25

    About

    A django rest framework restaurant management system with 2 working apps utilizing a single database and one as to many ccommunication

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published