-
Notifications
You must be signed in to change notification settings - Fork 1
How to Connect Django to MySQL
It is assumed that you have cloned the repository and created a virtual environment.
Before starting development, we need to install MySQL Client. Inside the ./backend
directory:
# Install MySQL Client
pip install mysqlclient
In your Django project's settings.py file, you need to configure the database settings. Here's an example of how you can configure Django to use MySQL:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'your_database_name',
'USER': 'your_mysql_username',
'PASSWORD': 'your_mysql_password',
'HOST': 'localhost', # Or your MySQL server's IP address
'PORT': '3306', # Default MySQL port
}
}
After configuring the database settings, you need to create the database tables by running Django's migrate
command:
python manage.py migrate
You can now start your Django development server and test if the connection to the MySQL database is working. Inside the ./backend
directory:
# Run the Django project server
python manage.py runserver
If everything is configured correctly, your Django application should be able to connect to the MySQL database.
Congratulations! You have connected Django to MySQL.
Turquiz App
DONE
- Lab Report #1
- Lab Report #2
- Lab Report #3
- Lab Report #4
- Lab Report #5
- Lab Report #6
- Lab Report #7
- Lab Report for Lab 9
- Lab Meeting #1
- Meeting #1
- Lab Meeting #2
- Meeting #2
- Project Plan Meeting
- Frontend Meeting #1
- Lab Meeting #3
- Meeting #3
- Meeting #4
- Lab Meeting #4
- Meeting #5
- Meeting #6
- Meeting #7
- Meeting #8
- User Scenario 1 - Explore and Register
- User Scenario 2 - Search for a Quiz & Create a Quiz
- User Scenario 3 - Take & Review a Quiz
- User Scenario 4 - Search Forum & Bookmark & Upvote & Answer
- User Scenario 5 - User Badges
- User Scenario Template
- User Stories