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
- SQLite Viewer by qwtel.com aka Florian Klampfer
- Install Git from https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
- Install Github Cli for your local machine https://cli.github.com/manual/installation
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/
# 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.
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
Solution : inside vscode press ctrl + shift + p
the prompt below will appear , type/select interpreter
Solution : inside vscode then search for your virtual environment (it'll have the folder name you ran the commands in)
Result : inside vscode in the terminal, you'll see the environment is now the same as the one you selected
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.)
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