How to start a Django Rest Framework Project in github

How to start a Django Rest Framework Project in github

Let's assume that your project will be call citiesprj, and your project folder ~/projects, your first app will be called cities and your env will be called cities too.

  1. Create your account in github if you don't have one already
  2. Create a new repository(use in .gitignore python template)
  3. Install git in your desktop compueter(it will be different depending on your OS)
  4. cd to the folder where you have your projects
  5. git clone https://github.com/<your user in github>/citiesprj
  6. cd to ~/projects/citiesprj
  7. Use Virtual Environment Wrapper to handle your virtual environments.
  8. mkvirtual env cities
  9. mkdir requirements
  10. mkdir requiremtns/python
  11. vi requirements/python/base.txt 
    • pip install Django==1.9.5
      pip install djangorestframework==3.3.3
      pip install django-rest-swagger==0.3.6
  12. pip install -r requirements/python/base.txt
  13. cd citiesprj/apps
  14. django-admin.py startapp cities

  15. cd ../../
  16. vi citiesprj/settings.py
  17. add 'citiesprj.apps.cities' to your INSTALLED_APPS tuple
  18. ready to start adding Django stuff now

We use this structure base on 

Two Scoops of Django: Best Practices for Django 1.8

and our experience in different jobs. We also include a bash file cli-test.sh in the root directory of the project with this info:

#!/bin/bash
./manage.py test -- $1

Once you have created your skeleton you are ready to your first commit to github

I use PyCharm so I add .idea/ to my .gitignore file

git add .
git commit -m "first commit -> project skeleton"
git push origin master

Good luck!!!

Current rating: 3