HOW DOES THIS WORK?
- After downloading project we need to create virtaul env and install dependencies from requirements.txt using command:
pip install -r requirements.txt
Important thing is to put database file called car_rental.sql on localhost so mysql connector can connect to it:
cnx = mysql.connector.connect(
host='localhost',
user='root',
database='car_rental',
)
Of course we have to install MySQL first if we don’t have it on our computer, you can find it here: https://dev.mysql.com/downloads/installer/
car_rental.sql can be imported to mysql workbench or xampp so our program will connect to a database
- Then we have to activate virtual env, go to project directory and run it through command:
python manage.py runserver
- And here is what we see when we type http://localhost:8000/ in our browser:
- We can choose date and click SZUKAJ SAMOCHODÓW:
- Filter cars and click WIĘCEJ:
- Rent a car by clicking WYNAJMIJ and choose interesting us options the click DALEJ:
- Fill formula and last click – WYNAJMIJ:
- Congratulations! You rented fake car:
We can see here info that we received an email on typed earlier address but this option works if we configure it in app settings.
-
to do this go to settings.py file and edit this lines of code:
EMAIL_HOST = ‘smtp.gmail.com’ EMAIL_PORT = 587 EMAIL_HOST_USER = ‘’ EMAIL_HOST_PASSWORD = ‘’ EMAIL_USE_TLS = True
More info here: https://data-flair.training/blogs/django-send-email/
-
then go to views.py in blog folder and uncomment this code:
#m = EmailMessage( # subject='Carnet Order', # body='Szczegóły zamówienia w załączniku', # from_email='[email protected]', # to=[e_mail], #) #m.attach('zamowienie', result.getvalue(), 'application/pdf') #.send()```
IMPORTANT! Instead of from_email='[email protected]'
type email that you passed in settings.py file.
- To see admin panel go to http://localhost:8000/admin/ in your browser