A friend sent me a Django question a few days ago. Specifically:
May I ask the second chapter in the Django practice you gave me?
Refreshing your first Django Project
Step by step, follow his instructions. Because I encountered an error in the folder where Django was installed, I saw a folder on the same disk.
In Django-projects, the setting in setting is 'name': 'd: \ Django-project '.
Last run
Unable to open database file
. After reading the online statement, the write and read permissions for folders are modified, but the error is still the same.
I don't know why.
I used Django's last version 2.7.1. I don't know if I didn't bring SQLite at all?
Solution:
Error: Unable to open database file descriptionProgramFiles cannot be opened. There are two possible cases:
1. The program does not have the permission to open the folder where the database is located. If you are developing in windows, this problem does not exist.
2. The database path is incorrect.
This friend is developed in windows, so there is no first case. The error should be caused by incorrect database path settings.
Solution:
Import OS
DEBUG = true
Template_debug = debug
Site_path = OS. Path. dirname (OS. Path. abspath (_ file _) # The system path can be customized.
Admins = (
# ('Your name', 'Your _ email@domain.com '),
)
Managers = admins
Database_engine = 'sqlite3 '# 'postgresql _ psycopg2', 'postgresql ', 'mysql', 'sqlite3 'or 'oracle '.
Database_name = OS. Path. Join (site_path, 'guestbook. db') database files are placed in the root directory of the folder.
By the way, python uses the SQLite database by default.
We hope this example can help you avoid some mistakes.