Django server for Travel Mate (Project: nomad)
Django 2.0 server for Travel Mate
git clone https://github.com/project-travel-mate/server && cd server
pip install virtualenv
virtualenv venv --python=python3.6
Now activate the environment shell with:
source venv/bin/activate # On Linux
or
venv\Scripts\activate & :: On Windows
pip install -r requirements.txt
For Linux-
$ sudo -u postgres createuser nomad
$ sudo -u postgres createdb nomad
$ sudo -u postgres psql
psql=# alter user nomad with encrypted password 'pass';
psql=# grant all privileges on database nomad to nomad ;
psql=# ALTER USER nomad CREATEDB ;
For Windows-
The complete path>psql -U postgres -h localhost
Password:The one given during setup of postgres.
postgres=# create database nomad;
postgres=# create user nomad;
postgres=# alter user nomad with encrypted password 'pass';
postgres=# grant all privileges on database nomad to nomad ;
postgres=# ALTER USER nomad CREATEDB ;
python manage.py makemigrations
python manage.py migrate
python manage.py test
python manage.py runserver
Open localhost:8000
python manage.py createsuperuser
When prompted, type your username (lowercase, no spaces), email address, and password. For example, the output should look like this:
Username: nomadadmin
Email address: [email protected]
Password:
Password (again):
Superuser created successfully.
python manage.py runserver
Open localhost:8000/admin
You would need to have a registered user, with which you can generate a authentication token. Follow the following steps to generate a token (You can download Postman client to make the following POST calls) Reference: TokenAuthentication API docs
/api/sign-up
with 4 form-data body objects: email
, password
, firstname
, lastname
. You should get "Successfully registered" response with 201 status code./api/sign-in
with 2 form-data body objects: username
(which is your email Id you used for sign up), password
. You will get a token in JSON response, store it somewhere.Authorization: Token <your token>