Skip to content

Latest commit

 

History

History
192 lines (145 loc) · 5.78 KB

README.md

File metadata and controls

192 lines (145 loc) · 5.78 KB

django-twitter

Build Status codecov Codacy Badge Codacy Badge pylint Score

Contents

Run Service on Your Machine

Pre-install

Prepare Environment

  • Clone this Repo

    host$ git clone git@github.com:W-Shih/django-twitter.git
  • Prepare Vagrantfile

    The simplest way is to use Vagrantfile-bak as the template.

    host$ cp Vagrantfile-bak Vagrantfile
  • Prepare local_settings.py

    The simplest way is to use ./twitter/local_settings.example.py as the template. However, you need to set up your own AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY so that users are able to upload their avatars to Amazon S3.

    host$ cd twitter/
    host$ cp local_settings.example.py local_settings.py
  • Initial VM

    host$ vagrant up
  • VM settings (optional)

    • Virtual Box

      • Use 4 CPUs at least
      • Use 2048 MBs for memory at least
    • Modify .bashrc

      host$ vagrant ssh
      vm$ sudo vi ~/.bashrc
      • add cd /vagrant on the top
      • force_color_prompt=yes

Database Migration

  • Migration

    vm$ python manage.py migrate
  • Create superuser

    • Method 1 - manually create superuser by

      vm$ python manage.py createsuperuser 
    • Method 2 - create superuser by provision.sh

      provision.sh already has the script to create superuser, so could simply run the following in the host machine:

      host$ vagrant provision

      This way will create a superuser with username admin and password admin. Please refer to provision.sh for details.

Ready to Go

Now you are all set. You should be able to run this service on your machine.

  • Run tests

    vm$ coverage run --source='.' manage.py test && coverage report -m && coverage html && cove rage xml

    or simply

    vm$ python manage.py test
  • Run pylint

    vm$ touch __init__.py; pylint $(pwd); rm __init__.py
  • Check MySQL's initialization

    The default password for MySQL was yourpassword set up by provision.sh. Please refer to provision.sh for details.

    vm$ mysql -uroot -p
    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sys                |
    | twitter            |
    +--------------------+
    mysql> use twitter;
    mysql> show tables;
    +----------------------------+
    | Tables_in_twitter          |
    +----------------------------+
    | accounts_userprofile       |
    | auth_group                 |
    | auth_group_permissions     |
    | auth_permission            |
    | auth_user                  |
    | auth_user_groups           |
    | auth_user_user_permissions |
    | comments_comment           |
    | django_admin_log           |
    | django_content_type        |
    | django_migrations          |
    | django_session             |
    | friendships_friendship     |
    | likes_like                 |
    | newsfeeds_newsfeed         |
    | notifications_notification |
    | tweets_tweet               |
    | tweets_tweetphoto          |
    +----------------------------+  
  • Run the service

    • Start the service on your local machine

      vm$ python manage.py runserver 0.0.0.0:8000
    • Access http://localhost/ for twitter-backend APIs

    • Access http://localhost/admin/ for Django-twitter administration