1
Install
Benjamyn Love edited this page 2020-10-22 02:26:36 -04:00
First step clone the repo
git clone ssh://git@ssh.git.lovelynet.net:9001/The_Bois/MigratorProject.git
[benjamyn@bendev newdep]$ git clone ssh://git@ssh.git.lovelynet.net:9001/The_Bois/MigratorProject.git
Cloning into 'MigratorProject'...
remote: Counting objects: 137, done.
remote: Compressing objects: 100% (126/126), done.
remote: Total 137 (delta 57), reused 0 (delta 0)
Receiving objects: 100% (137/137), 16.94 KiB | 4.24 MiB/s, done.
Resolving deltas: 100% (57/57), done.
cd to MigratorProject and create a virtualenv
[benjamyn@bendev newdep]$ cd MigratorProject/
[benjamyn@bendev MigratorProject]$ ls
migratorapi README.md requirements.txt
[benjamyn@bendev MigratorProject]$ python3 -m venv env
[benjamyn@bendev MigratorProject]$ ls
env migratorapi README.md requirements.txt
[benjamyn@bendev MigratorProject]$
Activate the VirtualEnv
[benjamyn@bendev MigratorProject]$ source env/bin/activate
(env) [benjamyn@bendev MigratorProject]$
Install the project requirements
(env) [benjamyn@bendev MigratorProject]$ pip install -r requirements.txt
Collecting django (from -r requirements.txt (line 1))
Using cached https://files.pythonhosted.org/packages/50/22/4c91847beceadbb54b5a518909ed5000bb1777168c7d6b087e8f79e5e05b/Django-3.1.2-py3-none-any.whl
Collecting django-rest-framework (from -r requirements.txt (line 2))
Using cached https://files.pythonhosted.org/packages/ed/d2/61159bc6efd1bf16adc4a2a48f7ace2080d1f7aef054f606d1857cab490c/django-rest-framework-0.1.0.tar.gz
Collecting mysqlclient (from -r requirements.txt (line 3))
Using cached https://files.pythonhosted.org/packages/a5/e1/e5f2b231c05dc51d9d87fa5066f90d1405345c54b14b0b11a1c859020f21/mysqlclient-2.0.1.tar.gz
Collecting sqlparse>=0.2.2 (from django->-r requirements.txt (line 1))
Using cached https://files.pythonhosted.org/packages/14/05/6e8eb62ca685b10e34051a80d7ea94b7137369d8c0be5c3b9d9b6e3f5dae/sqlparse-0.4.1-py3-none-any.whl
Collecting pytz (from django->-r requirements.txt (line 1))
Using cached https://files.pythonhosted.org/packages/4f/a4/879454d49688e2fad93e59d7d4efda580b783c745fd2ec2a3adf87b0808d/pytz-2020.1-py2.py3-none-any.whl
Collecting asgiref~=3.2.10 (from django->-r requirements.txt (line 1))
Using cached https://files.pythonhosted.org/packages/d5/eb/64725b25f991010307fd18a9e0c1f0e6dff2f03622fc4bcbcdb2244f60d6/asgiref-3.2.10-py3-none-any.whl
Collecting djangorestframework (from django-rest-framework->-r requirements.txt (line 2))
Using cached https://files.pythonhosted.org/packages/a7/97/a2a6e4a8d909caa71a2acefead18bba2101dba0668c8b8d913ae3c4ee329/djangorestframework-3.12.1-py3-none-any.whl
Installing collected packages: sqlparse, pytz, asgiref, django, djangorestframework, django-rest-framework, mysqlclient
Running setup.py install for django-rest-framework ... done
Running setup.py install for mysqlclient ... done
Successfully installed asgiref-3.2.10 django-3.1.2 django-rest-framework-0.1.0 djangorestframework-3.12.1 mysqlclient-2.0.1 pytz-2020.1 sqlparse-0.4.1
NOTE if you get errors installing the mysqlclient package you need mariadb-devel, python3-devel
Create the database user (full permissions required for tests)
Open the mysql client
For Dev
create user 'USERNAME'@'localhost' identified by 'PASSWORD';
grant all privileges on *.* to 'USERNAME'@'localhost';
For Prod
create user 'USERNAME'@'localhost' identified by 'PASSWORD';
create database DBNAME;
grant all privileges on DBNAME.* to 'USERNAME'@'localhost';
Edit the migratorapi/migratorapi/settings.py file and add in your database details
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'DBNAME',
'USER': 'DBUSER',
'PASSWORD': 'PASSWORD',
'HOST': '127.0.0.1',
'PORT': '3306',
}
}
Also while you are here adjust your ALLOWED_HOSTS to use your dev IP
ALLOWED_HOSTS = ['10.6.9.42']
Then cd into migratorapi and run the DB migrations
(env) [benjamyn@bendev MigratorProject]$ cd migratorapi/
(env) [benjamyn@bendev migratorapi]$ python manage.py migrate
Operations to perform:
Apply all migrations: admin, api, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying api.0001_initial... OK
Applying api.0002_auto_20201018_1256... OK
Applying api.0003_auto_20201018_1259... OK
Applying api.0004_auto_20201020_1855... OK
Applying api.0005_auto_20201020_1915... OK
Applying api.0006_migration_uuid... OK
Applying api.0007_auto_20201021_1802... OK
Applying api.0008_auto_20201021_1805... OK
Applying api.0009_migration_is_urgent... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying auth.0010_alter_group_name_max_length... OK
Applying auth.0011_update_proxy_permissions... OK
Applying auth.0012_alter_user_first_name_max_length... OK
Applying sessions.0001_initial... OK
Then create a super user
(env) [benjamyn@bendev migratorapi]$ python manage.py createsuperuser
Username (leave blank to use 'benjamyn'): admin
Email address:
Password:
Password (again):
Superuser created successfully.
Finally you can run the application using
(env) [benjamyn@bendev migratorapi]$ python manage.py runserver 0.0.0.0:8000
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
October 22, 2020 - 17:26:00
Django version 3.1.2, using settings 'migratorapi.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.