Python Django project with PyCharm - kimduho/webdev GitHub Wiki

  • start from virtual machine side
$ mkdir ~/src/test_django; cd ~/src/test_djagno;
$ virtualenv --python=/usr/bin/python3.5 env;
$ source env/bin/activate; # for pip environment activation
$ pip freeze;
$ deactivate; # for deactivation purpose
  • next in local
$ mkdir ~/src/; cd ~/src/;
$ git clone https://<bitbucket_user_id>@bitbucket.org/<group_name>/test_django.git test_django;
  • next in PyCharm
    • create new django project: Django --> (Location) /home/<user_id>/src/test_django/; (remote env) SSH Credentials --> Host / User name / Auth type (password) / Password / / /home/<user_id>/src/test_django/env/bin/python; --> (Interpreter) 3.5.2 at ssh://<user_id>@:...
    • Remote project location: /home/<user_id>/src/test_django
    • More Settings --> Disable Django admin
    • Create --> create a project from existing sources instead
  • PyCharm Project Settings
    • Interpreter Settings
      • File --> Settings --> Project: test_django --> Project Interpreter --> Apply (for newer pip package installation)
    • Deployment Settings
      • File --> Settings --> Build, Execution, Deployment --> Deployment
      • Add ( + ): (Name) unat test_django
      • Connection: SFTP / (host) unat.com / (Root path) /home/<user_id>/src/test_django, (User name) <user_id>, (Auth) , (Web server root) http://<vm_hostname>
      • Mappings: (Local path) /home/<user_id>/src/test_django --> (Deployment path) / --> (Web path) /
    • Diff and Merge Tool Settings
      • File --> Settings --> Tools --> Diff & Merge --> External Diff Tools
      • [v] Use external diff tool: (Path) /usr/bin/meld, (Parameters) %1 %2 %3
      • [v] Use external merge tool: (Path) /usr/bin/meld, (Parameters) %1 %2 %3
    • Auto Upload Settings
      • Tools --> Deployment --> Automatic Upload --> (default server) 'unat test_django'
    • Run Configuration
      • Run --> Edit Configuration --> (Name) test_django --> (tab) Configuration
      • (Host) , (Port) 8100 (base port number is 8000), [v] Run browser --> 'OK'
    • Deployment Options
      • Tools --> Deployment --> Options
      • (Exclude items by name) .svn;.cvs;.idea;.DS_Store;.git;.hg;node_modules
  • Upload Source Codes
    • (right click) Project --> Synchronize 'test_django'
    • (or right click) Project --> Upload to 'unat test_django'
  • In remote virtual machine
    • install django and needed packages
$ cd ~/src/test_django; source env/bin/activate;
$ pip install -r ./requirements.txt;  # or
$ pip install <python_package_file_name>.tar.gz
$ pip install Pillow==3.4.2;  # if image handling package is in need
$ vi .env;  # setup environment parameters for python decouple
⚠️ **GitHub.com Fallback** ⚠️