JHS Car Rental is a car rental service webapp built using Django. Below is everything you need to get started with the JHS Car Rental app.
You will first need to install python 3 and pip
. If you have done this successfully then on windows you should be able to run:
Windows
python --version
and pip --version
MacOS/Linux
python3 --version
and pip3 --version
You should see Python 3.X.X
(number may be different but anything 3.8+ is fine) and
pip 21.0.1 from c:\users\YOUR_USERNAME\appdata\local\programs\python\python39\lib\site-packages\pip (python 3.X)
(Just make sure the python version number in brackets matches the number from above) respectively
If you have never used Django I would highly recommend looking into either the official tutorial, or the Mozilla Tutorial, or the [video crash course]((2) Python Django Crash Course - YouTube).
To install Django run:
Windows
pip install django
MacOS/Linux
pip3 install django
or sudo pip3 install django
To make sure it's installed properly run django-admin help
and you should see:
Type 'django-admin help <subcommand>' for help on a specific subcommand.
Available subcommands:
[django]
check
compilemessages
... # list continues
To make sure you all required dependencies installed, run pip install -r requirements.txt
To setup the database, run python manage.py makemigrations
followed by python manage.py migrate
Next step is to create an admin to access the admin panel. To do so, run python manage.py createsuperuser
and follow the instructions.
To run the project simply run python manage.py runserver
and you can naviagte to http://localhost:8000 to see the server.
At the top level there are a few files README.md
(what you're reading), manage.py
and .gitignore
. manage.py
does not need to be touched, it is the file that runs when you start the app, and is setup by default from Django. .gitignore
is used to ignore files that we don't need in the git repo (caches of files etc.).
The rest of the folders are the actual code. Django itself is structured into an app/project distinction, so I will tailor the rest of the documentation around that.
everything inside /carrentalapp
is the "project". Amoung other things this contains:
- The list of installed apps
- The global URL list
- The settings that are global across all apps
- Boilerplate file for running the server (wsgi and asgi)
You can think of this folder as mainly the server configuration, and each app as more of a particular peice of functionality.
Each app is essentially a particular peice of functionality that includes:
- The backend code (the models that drive the views that render the frontend templates)
- The frontend templates associated with the functionality
- Any additional URL routing changes that need to be made or URL patterns that need to be defined
There are a few apps inside the project, and they are detailed below.
This app contains the models, views and templates associated with getting the user logged in and accessing their data. One thing to note here is that the current homepage for the site exists here (in /users/templates/users/index.html
)
This app contains the api endpoints implementaion using djangorestframework.