Skip to content

Giovan/Django-REST-Framework_tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django REST Framework Tutorial

This is the final project of the django REST Framework as you can find in the oficial webpage.

Find the original repo for project structure and names in the oficial repo.

Pre-requisites

It make use of Pipenv a wonderful tool that aims to bring the best of all packaging worlds to the Python world. Extracted from the oficial documentation.

Installation with brew is simple as:

brew install pipenv

("assuming that you are using mac os")

Give a start to the Pipenv repo and also you can say thanks to kennethreitz for the awesome job in this wonderful tool.

Installation

Run:

pipenv install

Automatically retrieves the packages saved previously in the Pipfile.lock

Running

Use:

pipenv shell

To enter in the pipenv interactive mode

Then run:

python3 manage.py migrate

It will create the database in sqlite format and also run migrations for tables creation; sqlite is used for tutorial version and easy access to functionalities, in your product use a stable and production ready database (Poastgres, MySQL, Mongo, Oracle)

*Recommended superuser(admin) creation, it will helps to manage data in the UI

python3 manage.py createsuperuser

Then we can run the project as simple as:

python3 manage.py runserver

You get this response in console:

drf-console-run

Project in action

drf-snippets

Test in console -

GET:

drf-get-method-runnig

POST:

drf-snippets-post-method-ok

Base

Directory Tree

tree

Doesn't works?

brew install tree

Project structure:

.
├── Pipfile
├── Pipfile.lock
├── apiconfig
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── db.sqlite3
├── manage.py
├── readme.md
└── snippets
    ├── __init__.py
    ├── admin.py
    ├── apps.py
    ├── migrations
    │   ├── 0001_initial.py
    │   └── __init__.py
    ├── models.py
    ├── permissions.py
    ├── serializers.py
    ├── serializers.py.bak
    ├── tests.py
    ├── urls.py
    ├── urls.py.bak
    ├── views.mixins.py.bak
    ├── views.py
    └── views.py.bak

Changes