This project uses python 3.9,using other python version may cause some problems
install package by pip
pip install -r requirements/base.txt
if working for production, need to install production.txt
pip install -r requirements/production.txt
To connect sql server, we need to install microsoft ODBC driver
This project uses ODBC Driver 13 for SQL Server
download windows installer and install
please follow steps from microsoft official web
create .sql
in root path, MSSQL_HOST
and TEST_MSSQL_HOST
can't be the same
.sql
MSSQL_HOST=<host>
MSSQL_NAME=djangoproject
MSSQL_USERNAME=<username>
MSSQL_PASSWORD=<password>
USE_MSSQL_FAKE_DATA=True
TEST_MSSQL_HOST=<host>
TEST_MSSQL_NAME=djangoproject
TEST_MSSQL_USERNAME=<username>
TEST_MSSQL_PASSWORD=<password>
USE_MSSQL_FAKE_DATA=True
python manage.py check
django has some default migrations that we need to migrate, so run command below
migrate to database
python manage.py migrate
(optional) if we create some apps, we need to create migrations for apps
create migrations
python manage.py makemigrations
migrate for specify app
python manage.py migrate app_name
migrate for specify app migrations number
python manage.py migrate app_name 0001
revert migrate
python manage.py migrate app_name zero
python manage.py shell
The sample views in sqlserver/views.py
has a decorator of login_required
, meaning you will need to login to see the page. Therefore, you will need to create an user. Yod could run python manage.py createsuperuser
and follow the instructions to create a superuser to test the functionality of the app.
python manage.py runserver
run server for specify settings file
python manage.py runserver --settings=django_tutorial.settings_test
run server for specify settings ip and port
python manage.py runserver 0.0.0.0:8001
when testing, we need to specify settings file for testing
python manage.py test --settings=django_tutorial.settings_test