Where is the SQLite database created automatically by django?
I am doing settings.py file in the django tutorial and I am confused what I put into the NAME field. I want to use SQLite, so my understanding is that I don't need to create anything and the database will be created automatically? If so, where will it be created and what will it be called?
I tried running manage.py syncdb and got: "django.co开发者_JS百科re.exceptions.ImproperlyConfigured: Please fill out the database NAME in the settings module before using the database."
So I am guessing I should fill in the NAME file, but this is not what I understood in the directions below:
https://docs.djangoproject.com/en/1.3/intro/tutorial01/
NAME -- The name of your database. If you're using SQLite, the database will be a file on your computer; in that case, NAME should be the full absolute path, including filename, of that file. If the file doesn't exist, it will automatically be created when you synchronize the database for the first time (see below).
Well, as it says in the documentation, it will create the SQLite3 database file at the file location you configure at NAME
. Django doesn't guess but uses the file path you specify there.
Only if you use something other than SQLite, the NAME
will be the actual database name on the database server.
Create a .db file or install sqlite on your machine create a database file and point to it in settings.py under NAME for example i have "'/home/username/project/chatdb' thats on linux. for windows its 'C:/homes/user/mysite/sqlite3.db'
According to the actual docs (January 2015):
NAME – The name of your database. If you’re using SQLite, the database will be a file on your computer; in that case, NAME should be the full absolute path, including filename, of that file. The default value, os.path.join(BASE_DIR, 'db.sqlite3'), will store the file in your project directory.
As written, I recommend as Name
os.path.join(BASE_DIR, 'db.sqlite3')
. Of course, you have to define BASE_DIR
精彩评论