Карта ДТП
Проект "Карта ДТП" (https://dtp-stat.ru)
Обсуждение проекта - https://t.me/crash_map
bash $ npm install -g npx $ npm install
bash pip install -r requirements.txt
bash $ psql -c "CREATE DATABASE django;" -U postgres $ psql -c "CREATE ROLE django WITH LOGIN PASSWORD 'django';" -U postgres $ psql -c "ALTER ROLE django CREATEDB;" -U postgres $ psql -c "GRANT ALL PRIVILEGES ON DATABASE django TO django;" -U postgres
DATABASE_URL(used by app for database connection) and
DEBUGenvironment variable with database info according to previous steps:
bash $ export DATABASE_URL="postgres://django:[email protected]:5432/django" $ export DEBUG=true
bash $ ./manage.py makemigrations --noinput $ ./manage.py migrate --noinput
default_cachecache table:
bash $ ./manage.py createcachetable
It`s time to start app:
bash $ ./manage.py runserver localhost:8000Authorize on http://127.0.0.1:8000/admin1.
You need to run
npm starttogether with app to generate JavaScript-code:
bash npm start
Project configured by
.dockerenvfile in docker folder.
Rename
docker/.dockerenv.exampleto
docker/.dockerenvand set variables:
SECRET_KEY, - secret key, you can generate it with:
python3 -c "import random, string; print('SECRET_KEY=\"%s\"'%''.join([random.SystemRandom().choice(\"{}{}{}\".format(string.ascii_letters, string.digits, string.punctuation)) for i in range(63)]))"
DEBUG, - set it to
true
docker-compose up -d --build
Run this and follow instructions:
$ docker-compose exec app ./manage.py createsuperuser --email [email protected] --username admin
Загрузить в базу техническую информацию (названия разделов)
$ ./parser.py tech_data
Загрузить в базу регионы и районы
$ ./parser.py get_regions
Загрузить в базу все ДТП. Для этого нужно предварительно скачать дамп всех ДТП и положить в папку data - https://drive.google.com/file/d/1aUTPLqUX5xZhmtcFODyVb7GpBj3_SHui/view?usp=sharing
$ ./parser.py get_dtp
Чтобы включить отображение региона нужно в базе данных поставить ему status = True.
Запустите эту команду перед развертыванием для генерации JavaScript кода:
$ npm run build-production
Если не хочется выкачивать все данные - вот бекап базы https://drive.google.com/open?id=1SPHyY-802U-USRQh3j4JfzhIO86eAaUp
dtpmap/.env.tmpl -> dtpmap/.env
dtpmap/.env
(самый простой способ) - Ставите Node.js https://nodejs.org/en/ - Ставите yarn https://yarnpkg.com/en/docs/install - В корне проекта выполняете
yarnи затем
yarn start
Выполнить
manage.py runserver 8000