Sankalp-2664 / Student-Result-Management

0 stars 0 forks source link

Django Database Connectivity #1

Open Adwait34 opened 2 days ago

Adwait34 commented 2 days ago

I have connected Django application(beta) with MySQL database. When I make changes in Django administration, the changes are visible but, they are not getting reflected in the MySQL database (I tried testing it through cmd line).

Fresh approach: First, I am going to create a new database(student_report) without tables, then create models and run migrations and will check if the issue still persists.

alwinvargh commented 2 days ago

It sounds like you're on the right track by creating a new database and checking if the issue persists.

Create a New Database, In your Django project's settings.py, update the DATABASES section to point to the new database:

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'student_report', 'USER': 'your_username', 'PASSWORD': 'your_password', 'HOST': 'localhost', # or your database host 'PORT': '3306', # or your database port } } Define your models in the models.py file of your Django app.

Run Migrations,After running migrations, you can check if the tables are created

Use Django Admin: Access the Django admin panel, create some entries, and then verify ,If changes in the admin panel still don’t reflect in the database, check:

Database connection errors in the Django logs. Django settings to ensure the correct database is being used. Any errors that might occur during save operations in the Django shell. Verify Transactions: If you’re using transactions or any custom save logic, ensure that they’re committed properly.

By following these steps, you should be able to determine if the issue lies with the database connection, Django configuration, or something else in your code. Let me know if you encounter any specific issues!