├── rest-tutorial-start ├── snippets │ ├── tests.py │ ├── admin.py │ ├── apps.py │ ├── __pycache__ │ │ ├── admin.cpython-36.pyc │ │ ├── models.cpython-36.pyc │ │ ├── urls.cpython-36.pyc │ │ ├── views.cpython-36.pyc │ │ └── __init__.cpython-36.pyc │ ├── migrations │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ └── 0001_initial.cpython-36.pyc │ │ └── 0001_initial.py │ ├── urls.py │ ├── models.py │ ├── templates │ │ └── snippets │ │ │ ├── snippet_detail.html │ │ │ └── snippet_list.html │ └── views.py ├── db.sqlite3 ├── rest-tutorial │ ├── __pycache__ │ │ ├── urls.cpython-36.pyc │ │ ├── wsgi.cpython-36.pyc │ │ ├── __init__.cpython-36.pyc │ │ └── settings.cpython-36.pyc │ ├── urls.py │ ├── wsgi.py │ ├── templates │ │ └── base.html │ └── settings.py └── manage.py ├── rest-tutorial-filtering ├── snippets │ ├── tests.py │ ├── admin.py │ ├── apps.py │ ├── __pycache__ │ │ ├── urls.cpython-36.pyc │ │ ├── admin.cpython-36.pyc │ │ ├── models.cpython-36.pyc │ │ ├── views.cpython-36.pyc │ │ └── __init__.cpython-36.pyc │ ├── api │ │ ├── __pycache__ │ │ │ ├── viewsets.cpython-36.pyc │ │ │ └── serializers.cpython-36.pyc │ │ ├── serializers.py │ │ └── viewsets.py │ ├── migrations │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ └── 0001_initial.cpython-36.pyc │ │ └── 0001_initial.py │ ├── urls.py │ ├── models.py │ ├── templates │ │ └── snippets │ │ │ ├── snippet_detail.html │ │ │ └── snippet_list.html │ └── views.py ├── db.sqlite3 ├── rest-tutorial │ ├── templates │ │ ├── registration │ │ │ └── login.html │ │ └── base.html │ ├── __pycache__ │ │ ├── urls.cpython-36.pyc │ │ ├── wsgi.cpython-36.pyc │ │ ├── router.cpython-36.pyc │ │ ├── __init__.cpython-36.pyc │ │ └── settings.cpython-36.pyc │ ├── router.py │ ├── wsgi.py │ ├── urls.py │ └── settings.py └── manage.py ├── rest-tutorial-authentication ├── snippets │ ├── tests.py │ ├── admin.py │ ├── apps.py │ ├── __pycache__ │ │ ├── urls.cpython-36.pyc │ │ ├── admin.cpython-36.pyc │ │ ├── models.cpython-36.pyc │ │ ├── views.cpython-36.pyc │ │ └── __init__.cpython-36.pyc │ ├── api │ │ ├── __pycache__ │ │ │ ├── viewsets.cpython-36.pyc │ │ │ └── serializers.cpython-36.pyc │ │ ├── serializers.py │ │ └── viewsets.py │ ├── migrations │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ └── 0001_initial.cpython-36.pyc │ │ └── 0001_initial.py │ ├── urls.py │ ├── models.py │ ├── templates │ │ └── snippets │ │ │ ├── snippet_detail.html │ │ │ └── snippet_list.html │ └── views.py ├── db.sqlite3 ├── rest-tutorial │ ├── templates │ │ ├── registration │ │ │ └── login.html │ │ └── base.html │ ├── __pycache__ │ │ ├── urls.cpython-36.pyc │ │ ├── wsgi.cpython-36.pyc │ │ ├── router.cpython-36.pyc │ │ ├── __init__.cpython-36.pyc │ │ └── settings.cpython-36.pyc │ ├── router.py │ ├── wsgi.py │ ├── urls.py │ └── settings.py └── manage.py ├── rest-tutorial-viewsets-and-routers ├── requirements.txt ├── snippets │ ├── tests.py │ ├── apps.py │ ├── admin.py │ ├── __pycache__ │ │ ├── admin.cpython-36.pyc │ │ ├── models.cpython-36.pyc │ │ ├── urls.cpython-36.pyc │ │ ├── views.cpython-36.pyc │ │ ├── __init__.cpython-36.pyc │ │ └── serializers.cpython-36.pyc │ ├── api │ │ ├── __pycache__ │ │ │ ├── views.cpython-36.pyc │ │ │ ├── viewsets.cpython-36.pyc │ │ │ └── serializers.cpython-36.pyc │ │ ├── serializers.py │ │ └── viewsets.py │ ├── migrations │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── 0001_initial.cpython-36.pyc │ │ │ ├── 0002_snippet_uuid.cpython-36.pyc │ │ │ └── 0003_remove_snippet_uuid.cpython-36.pyc │ │ ├── 0003_remove_snippet_uuid.py │ │ ├── 0002_snippet_uuid.py │ │ └── 0001_initial.py │ ├── templates │ │ └── snippets │ │ │ ├── snippet_detail.html │ │ │ ├── snippet_list.html │ │ │ └── base.html │ ├── urls.py │ ├── models.py │ └── views.py ├── db.sqlite3 ├── sampleapp │ ├── __pycache__ │ │ ├── urls.cpython-36.pyc │ │ ├── wsgi.cpython-36.pyc │ │ ├── router.cpython-36.pyc │ │ ├── __init__.cpython-36.pyc │ │ ├── api_urls.cpython-36.pyc │ │ └── settings.cpython-36.pyc │ ├── router.py │ ├── urls.py │ ├── wsgi.py │ └── settings.py └── manage.py └── README.md /rest-tutorial-start/snippets/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /rest-tutorial-filtering/snippets/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /rest-tutorial-start/snippets/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /rest-tutorial-authentication/snippets/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /rest-tutorial-filtering/snippets/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/requirements.txt: -------------------------------------------------------------------------------- 1 | Django==2.0.7 2 | djangorestframework==3.8.2 3 | pytz==2018.5 4 | -------------------------------------------------------------------------------- /rest-tutorial-authentication/snippets/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /rest-tutorial-start/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-start/db.sqlite3 -------------------------------------------------------------------------------- /rest-tutorial-filtering/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-filtering/db.sqlite3 -------------------------------------------------------------------------------- /rest-tutorial-authentication/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-authentication/db.sqlite3 -------------------------------------------------------------------------------- /rest-tutorial-start/snippets/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class SnippetsConfig(AppConfig): 5 | name = 'snippets' 6 | -------------------------------------------------------------------------------- /rest-tutorial-filtering/snippets/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class SnippetsConfig(AppConfig): 5 | name = 'snippets' 6 | -------------------------------------------------------------------------------- /rest-tutorial-authentication/snippets/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class SnippetsConfig(AppConfig): 5 | name = 'snippets' 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # django-rest-api-tutorial 2 | Create A REST API tutorial series: https://www.youtube.com/watch?v=tzlT__hx6sk&list=PLbpAWbHbi5rMV3H0S5IDK3cSRC1Jas3VP 3 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-viewsets-and-routers/db.sqlite3 -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class SnippetsConfig(AppConfig): 5 | name = 'snippets' 6 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import Snippet 3 | 4 | 5 | admin.site.register(Snippet) 6 | -------------------------------------------------------------------------------- /rest-tutorial-filtering/rest-tutorial/templates/registration/login.html: -------------------------------------------------------------------------------- 1 |
2 | {% csrf_token %} 3 | {{ form }} 4 | 5 |
6 | -------------------------------------------------------------------------------- /rest-tutorial-start/snippets/__pycache__/admin.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-start/snippets/__pycache__/admin.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-start/snippets/__pycache__/models.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-start/snippets/__pycache__/models.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-start/snippets/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-start/snippets/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-start/snippets/__pycache__/views.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-start/snippets/__pycache__/views.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-authentication/rest-tutorial/templates/registration/login.html: -------------------------------------------------------------------------------- 1 |
2 | {% csrf_token %} 3 | {{ form }} 4 | 5 |
6 | -------------------------------------------------------------------------------- /rest-tutorial-filtering/snippets/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-filtering/snippets/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-start/snippets/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-start/snippets/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-filtering/snippets/__pycache__/admin.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-filtering/snippets/__pycache__/admin.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-filtering/snippets/__pycache__/models.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-filtering/snippets/__pycache__/models.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-filtering/snippets/__pycache__/views.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-filtering/snippets/__pycache__/views.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-start/rest-tutorial/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-start/rest-tutorial/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-start/rest-tutorial/__pycache__/wsgi.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-start/rest-tutorial/__pycache__/wsgi.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-authentication/snippets/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-authentication/snippets/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-filtering/rest-tutorial/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-filtering/rest-tutorial/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-filtering/rest-tutorial/__pycache__/wsgi.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-filtering/rest-tutorial/__pycache__/wsgi.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-filtering/snippets/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-filtering/snippets/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-start/rest-tutorial/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-start/rest-tutorial/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-start/rest-tutorial/__pycache__/settings.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-start/rest-tutorial/__pycache__/settings.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-authentication/snippets/__pycache__/admin.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-authentication/snippets/__pycache__/admin.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-authentication/snippets/__pycache__/models.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-authentication/snippets/__pycache__/models.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-authentication/snippets/__pycache__/views.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-authentication/snippets/__pycache__/views.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-filtering/rest-tutorial/__pycache__/router.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-filtering/rest-tutorial/__pycache__/router.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-filtering/snippets/api/__pycache__/viewsets.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-filtering/snippets/api/__pycache__/viewsets.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-authentication/rest-tutorial/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-authentication/rest-tutorial/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-authentication/rest-tutorial/__pycache__/wsgi.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-authentication/rest-tutorial/__pycache__/wsgi.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-authentication/snippets/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-authentication/snippets/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-filtering/rest-tutorial/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-filtering/rest-tutorial/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-filtering/rest-tutorial/__pycache__/settings.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-filtering/rest-tutorial/__pycache__/settings.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-authentication/rest-tutorial/__pycache__/router.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-authentication/rest-tutorial/__pycache__/router.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-authentication/snippets/api/__pycache__/viewsets.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-authentication/snippets/api/__pycache__/viewsets.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-filtering/snippets/api/__pycache__/serializers.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-filtering/snippets/api/__pycache__/serializers.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-start/snippets/migrations/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-start/snippets/migrations/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/sampleapp/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-viewsets-and-routers/sampleapp/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/sampleapp/__pycache__/wsgi.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-viewsets-and-routers/sampleapp/__pycache__/wsgi.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/__pycache__/admin.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-viewsets-and-routers/snippets/__pycache__/admin.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/__pycache__/models.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-viewsets-and-routers/snippets/__pycache__/models.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-viewsets-and-routers/snippets/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/__pycache__/views.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-viewsets-and-routers/snippets/__pycache__/views.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-authentication/rest-tutorial/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-authentication/rest-tutorial/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-authentication/rest-tutorial/__pycache__/settings.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-authentication/rest-tutorial/__pycache__/settings.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-filtering/snippets/migrations/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-filtering/snippets/migrations/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-start/snippets/migrations/__pycache__/0001_initial.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-start/snippets/migrations/__pycache__/0001_initial.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/sampleapp/__pycache__/router.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-viewsets-and-routers/sampleapp/__pycache__/router.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-viewsets-and-routers/snippets/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-authentication/snippets/api/__pycache__/serializers.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-authentication/snippets/api/__pycache__/serializers.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/sampleapp/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-viewsets-and-routers/sampleapp/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/sampleapp/__pycache__/api_urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-viewsets-and-routers/sampleapp/__pycache__/api_urls.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/sampleapp/__pycache__/settings.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-viewsets-and-routers/sampleapp/__pycache__/settings.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/__pycache__/serializers.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-viewsets-and-routers/snippets/__pycache__/serializers.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/api/__pycache__/views.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-viewsets-and-routers/snippets/api/__pycache__/views.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-authentication/snippets/migrations/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-authentication/snippets/migrations/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-filtering/snippets/migrations/__pycache__/0001_initial.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-filtering/snippets/migrations/__pycache__/0001_initial.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/api/__pycache__/viewsets.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-viewsets-and-routers/snippets/api/__pycache__/viewsets.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/api/__pycache__/serializers.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-viewsets-and-routers/snippets/api/__pycache__/serializers.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-authentication/snippets/migrations/__pycache__/0001_initial.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-authentication/snippets/migrations/__pycache__/0001_initial.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-filtering/rest-tutorial/router.py: -------------------------------------------------------------------------------- 1 | from snippets.api.viewsets import SnippetViewSet 2 | from rest_framework import routers 3 | 4 | router = routers.DefaultRouter() 5 | router.register('snippets', SnippetViewSet, base_name='snippet') 6 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/migrations/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-viewsets-and-routers/snippets/migrations/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-authentication/rest-tutorial/router.py: -------------------------------------------------------------------------------- 1 | from snippets.api.viewsets import SnippetViewSet 2 | from rest_framework import routers 3 | 4 | router = routers.DefaultRouter() 5 | router.register('snippets', SnippetViewSet, base_name='snippet') 6 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/migrations/__pycache__/0001_initial.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-viewsets-and-routers/snippets/migrations/__pycache__/0001_initial.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/migrations/__pycache__/0002_snippet_uuid.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-viewsets-and-routers/snippets/migrations/__pycache__/0002_snippet_uuid.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-start/rest-tutorial/urls.py: -------------------------------------------------------------------------------- 1 | 2 | from django.contrib import admin 3 | from django.urls import path, include 4 | 5 | urlpatterns = [ 6 | path('snippets/', include('snippets.urls', namespace='snippets')), 7 | path('admin/', admin.site.urls), 8 | ] 9 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/migrations/__pycache__/0003_remove_snippet_uuid.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheDumbfounds/django-rest-api-tutorial/HEAD/rest-tutorial-viewsets-and-routers/snippets/migrations/__pycache__/0003_remove_snippet_uuid.cpython-36.pyc -------------------------------------------------------------------------------- /rest-tutorial-start/snippets/urls.py: -------------------------------------------------------------------------------- 1 | 2 | from django.urls import path, include 3 | from . import views 4 | 5 | app_name = 'snippets' 6 | urlpatterns = [ 7 | path('', views.SnippetListView.as_view(), name='list'), 8 | path('/', views.SnippetDetailView.as_view(), name='detail') 9 | ] 10 | -------------------------------------------------------------------------------- /rest-tutorial-filtering/snippets/urls.py: -------------------------------------------------------------------------------- 1 | 2 | from django.urls import path, include 3 | from . import views 4 | 5 | app_name = 'snippets' 6 | urlpatterns = [ 7 | path('', views.SnippetListView.as_view(), name='list'), 8 | path('/', views.SnippetDetailView.as_view(), name='detail') 9 | ] 10 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/sampleapp/router.py: -------------------------------------------------------------------------------- 1 | from snippets.api.viewsets import SnippetViewSet 2 | from rest_framework import routers 3 | 4 | router = routers.DefaultRouter() 5 | router.register('snippets', SnippetViewSet, base_name='snippet') 6 | 7 | # for url in router.urls: 8 | # print(url, '\n') 9 | -------------------------------------------------------------------------------- /rest-tutorial-authentication/snippets/urls.py: -------------------------------------------------------------------------------- 1 | 2 | from django.urls import path, include 3 | from . import views 4 | 5 | app_name = 'snippets' 6 | urlpatterns = [ 7 | path('', views.SnippetListView.as_view(), name='list'), 8 | path('/', views.SnippetDetailView.as_view(), name='detail') 9 | ] 10 | -------------------------------------------------------------------------------- /rest-tutorial-filtering/snippets/api/serializers.py: -------------------------------------------------------------------------------- 1 | from rest_framework import serializers 2 | from snippets.models import Snippet 3 | 4 | 5 | class SnippetSerializer(serializers.HyperlinkedModelSerializer): 6 | 7 | class Meta: 8 | model = Snippet 9 | fields = ('title', 'body', 'created') 10 | -------------------------------------------------------------------------------- /rest-tutorial-start/snippets/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | 4 | class Snippet(models.Model): 5 | title = models.CharField(max_length=100) 6 | body = models.TextField() 7 | created = models.DateTimeField(auto_now_add=True) 8 | 9 | def __str__(self): 10 | return self.title 11 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/api/serializers.py: -------------------------------------------------------------------------------- 1 | from rest_framework import serializers 2 | from snippets.models import Snippet 3 | 4 | 5 | class SnippetSerializer(serializers.ModelSerializer): 6 | 7 | class Meta: 8 | model = Snippet 9 | fields = ('title', 'body', 'created') 10 | -------------------------------------------------------------------------------- /rest-tutorial-authentication/snippets/api/serializers.py: -------------------------------------------------------------------------------- 1 | from rest_framework import serializers 2 | from snippets.models import Snippet 3 | 4 | 5 | class SnippetSerializer(serializers.HyperlinkedModelSerializer): 6 | 7 | class Meta: 8 | model = Snippet 9 | fields = ('title', 'body', 'created') 10 | -------------------------------------------------------------------------------- /rest-tutorial-filtering/snippets/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | 4 | class Snippet(models.Model): 5 | title = models.CharField(max_length=100) 6 | body = models.TextField() 7 | created = models.DateTimeField(auto_now_add=True) 8 | 9 | def __str__(self): 10 | return self.title 11 | -------------------------------------------------------------------------------- /rest-tutorial-start/snippets/templates/snippets/snippet_detail.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block title %}Snippet Detail{% endblock title %} 4 | 5 | {% block content %} 6 | 7 |

{{ snippet.title }}

8 | 9 |
10 |   {{ snippet.body_preview }}
11 | 
12 | 13 | {% endblock content %} 14 | -------------------------------------------------------------------------------- /rest-tutorial-authentication/snippets/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | 4 | class Snippet(models.Model): 5 | title = models.CharField(max_length=100) 6 | body = models.TextField() 7 | created = models.DateTimeField(auto_now_add=True) 8 | 9 | def __str__(self): 10 | return self.title 11 | -------------------------------------------------------------------------------- /rest-tutorial-filtering/snippets/templates/snippets/snippet_detail.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block title %}Snippet Detail{% endblock title %} 4 | 5 | {% block content %} 6 | 7 |

{{ snippet.title }}

8 | 9 |
10 |   {{ snippet.body_preview }}
11 | 
12 | 13 | {% endblock content %} 14 | -------------------------------------------------------------------------------- /rest-tutorial-authentication/snippets/templates/snippets/snippet_detail.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block title %}Snippet Detail{% endblock title %} 4 | 5 | {% block content %} 6 | 7 |

{{ snippet.title }}

8 | 9 |
10 |   {{ snippet.body_preview }}
11 | 
12 | 13 | {% endblock content %} 14 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/templates/snippets/snippet_detail.html: -------------------------------------------------------------------------------- 1 | {% extends 'snippets/base.html' %} 2 | 3 | {% block title %}Snippet Detail{% endblock title %} 4 | 5 | {% block content %} 6 | 7 |

{{ snippet.title }}

8 | 9 |
10 |   {{ snippet.body_preview }}
11 | 
12 | 13 | {% endblock content %} 14 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/urls.py: -------------------------------------------------------------------------------- 1 | 2 | from django.urls import path, include 3 | from rest_framework import routers 4 | from . import views 5 | 6 | app_name = 'snippets' 7 | urlpatterns = [ 8 | path('', views.SnippetListView.as_view(), name='list'), 9 | path('/', views.SnippetDetailView.as_view(), name='detail'), 10 | ] 11 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/sampleapp/urls.py: -------------------------------------------------------------------------------- 1 | 2 | from django.contrib import admin 3 | from django.urls import path, include 4 | from .router import router 5 | 6 | urlpatterns = [ 7 | path('snippets/', include('snippets.urls', namespace='snippets')), 8 | path('admin/', admin.site.urls), 9 | path('api/', include(router.urls), name='api') 10 | ] 11 | -------------------------------------------------------------------------------- /rest-tutorial-filtering/snippets/templates/snippets/snippet_list.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block title %}Snippet List{% endblock title %} 4 | 5 | {% block content %} 6 | 7 |
    8 | {% for snippet in snippet_list %} 9 |
  • 10 | {{ snippet.title }} 11 |
  • 12 | {% endfor %} 13 |
14 | 15 | {% endblock content %} 16 | -------------------------------------------------------------------------------- /rest-tutorial-start/snippets/templates/snippets/snippet_list.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block title %}Snippet List{% endblock title %} 4 | 5 | {% block content %} 6 | 7 |
    8 | {% for snippet in snippet_list %} 9 |
  • 10 | {{ snippet.title }} 11 |
  • 12 | {% endfor %} 13 |
14 | 15 | {% endblock content %} 16 | -------------------------------------------------------------------------------- /rest-tutorial-authentication/snippets/templates/snippets/snippet_list.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block title %}Snippet List{% endblock title %} 4 | 5 | {% block content %} 6 | 7 |
    8 | {% for snippet in snippet_list %} 9 |
  • 10 | {{ snippet.title }} 11 |
  • 12 | {% endfor %} 13 |
14 | 15 | {% endblock content %} 16 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | import uuid 3 | 4 | 5 | class Snippet(models.Model): 6 | title = models.CharField(max_length=100) 7 | body = models.TextField() 8 | created = models.DateTimeField(auto_now_add=True) 9 | 10 | def __str__(self): 11 | return self.title 12 | 13 | def body_preview(self): 14 | return self.body[:50] 15 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/templates/snippets/snippet_list.html: -------------------------------------------------------------------------------- 1 | {% extends 'snippets/base.html' %} 2 | 3 | {% block title %}Snippet List{% endblock title %} 4 | 5 | {% block content %} 6 | 7 |
    8 | {% for snippet in snippet_list %} 9 |
  • 10 | {{ snippet.title }} 11 |
  • 12 | {% endfor %} 13 |
14 | 15 | {% endblock content %} 16 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/migrations/0003_remove_snippet_uuid.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.7 on 2018-07-14 07:34 2 | 3 | from django.db import migrations 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('snippets', '0002_snippet_uuid'), 10 | ] 11 | 12 | operations = [ 13 | migrations.RemoveField( 14 | model_name='snippet', 15 | name='uuid', 16 | ), 17 | ] 18 | -------------------------------------------------------------------------------- /rest-tutorial-start/rest-tutorial/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for rest-tutorial project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "rest-tutorial.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /rest-tutorial-filtering/rest-tutorial/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for rest-tutorial project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "rest-tutorial.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/sampleapp/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for sampleapp project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sampleapp.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /rest-tutorial-authentication/rest-tutorial/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for rest-tutorial project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "rest-tutorial.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /rest-tutorial-start/rest-tutorial/templates/base.html: -------------------------------------------------------------------------------- 1 | {% load static %} 2 | 3 | 4 | 5 | 6 | 7 | 8 | {% block title %}{% endblock title %} 9 | 10 | 11 | 12 | {% block content %} 13 | 14 | {% endblock content %} 15 | 16 | 17 | -------------------------------------------------------------------------------- /rest-tutorial-filtering/rest-tutorial/templates/base.html: -------------------------------------------------------------------------------- 1 | {% load static %} 2 | 3 | 4 | 5 | 6 | 7 | 8 | {% block title %}{% endblock title %} 9 | 10 | 11 | 12 | {% block content %} 13 | 14 | {% endblock content %} 15 | 16 | 17 | -------------------------------------------------------------------------------- /rest-tutorial-authentication/rest-tutorial/templates/base.html: -------------------------------------------------------------------------------- 1 | {% load static %} 2 | 3 | 4 | 5 | 6 | 7 | 8 | {% block title %}{% endblock title %} 9 | 10 | 11 | 12 | {% block content %} 13 | 14 | {% endblock content %} 15 | 16 | 17 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/templates/snippets/base.html: -------------------------------------------------------------------------------- 1 | {% load static %} 2 | 3 | 4 | 5 | 6 | 7 | 8 | {% block title %}{% endblock title %} 9 | 10 | 11 | 12 | {% block content %} 13 | 14 | {% endblock content %} 15 | 16 | 17 | -------------------------------------------------------------------------------- /rest-tutorial-filtering/snippets/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render, get_object_or_404 2 | from django.http import HttpResponse 3 | from django.urls import reverse 4 | from .models import Snippet 5 | from django.views import View 6 | from django.views.generic import ListView, DetailView 7 | 8 | 9 | class SnippetListView(ListView): 10 | model = Snippet 11 | template_name = 'snippets/snippet_list.html' 12 | 13 | 14 | class SnippetDetailView(DetailView): 15 | model = Snippet 16 | template_name = 'snippets/snippet_detail.html' 17 | -------------------------------------------------------------------------------- /rest-tutorial-start/snippets/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render, get_object_or_404 2 | from django.http import HttpResponse 3 | from django.urls import reverse 4 | from .models import Snippet 5 | from django.views import View 6 | from django.views.generic import ListView, DetailView 7 | 8 | 9 | class SnippetListView(ListView): 10 | model = Snippet 11 | template_name = 'snippets/snippet_list.html' 12 | 13 | 14 | class SnippetDetailView(DetailView): 15 | model = Snippet 16 | template_name = 'snippets/snippet_detail.html' 17 | -------------------------------------------------------------------------------- /rest-tutorial-authentication/snippets/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render, get_object_or_404 2 | from django.http import HttpResponse 3 | from django.urls import reverse 4 | from .models import Snippet 5 | from django.views import View 6 | from django.views.generic import ListView, DetailView 7 | 8 | 9 | class SnippetListView(ListView): 10 | model = Snippet 11 | template_name = 'snippets/snippet_list.html' 12 | 13 | 14 | class SnippetDetailView(DetailView): 15 | model = Snippet 16 | template_name = 'snippets/snippet_detail.html' 17 | -------------------------------------------------------------------------------- /rest-tutorial-filtering/rest-tutorial/urls.py: -------------------------------------------------------------------------------- 1 | 2 | from django.contrib import admin 3 | from django.urls import path, include 4 | from .router import router 5 | from rest_framework.authtoken import views 6 | from django.contrib.auth.views import login 7 | 8 | urlpatterns = [ 9 | path('snippets/', include('snippets.urls', namespace='snippets')), 10 | path('admin/', admin.site.urls), 11 | path('api/', include(router.urls)), 12 | path('api-token-auth/', views.obtain_auth_token, name='api-token-auth'), 13 | path('login/', login, name='login') 14 | ] 15 | -------------------------------------------------------------------------------- /rest-tutorial-authentication/rest-tutorial/urls.py: -------------------------------------------------------------------------------- 1 | 2 | from django.contrib import admin 3 | from django.urls import path, include 4 | from .router import router 5 | from rest_framework.authtoken import views 6 | from django.contrib.auth.views import login 7 | 8 | urlpatterns = [ 9 | path('snippets/', include('snippets.urls', namespace='snippets')), 10 | path('admin/', admin.site.urls), 11 | path('api/', include(router.urls)), 12 | path('api-token-auth/', views.obtain_auth_token, name='api-token-auth'), 13 | path('login/', login, name='login') 14 | ] 15 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/migrations/0002_snippet_uuid.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.5 on 2018-06-28 07:20 2 | 3 | from django.db import migrations, models 4 | import uuid 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('snippets', '0001_initial'), 11 | ] 12 | 13 | operations = [ 14 | migrations.AddField( 15 | model_name='snippet', 16 | name='uuid', 17 | field=models.UUIDField(db_index=True, default=uuid.uuid4, editable=False), 18 | ), 19 | ] 20 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render, get_object_or_404 2 | from django.http import HttpResponse 3 | from django.urls import reverse 4 | from .models import Snippet 5 | from django.views.generic import ListView, DetailView 6 | from rest_framework import viewsets 7 | from .api.serializers import SnippetSerializer 8 | 9 | 10 | class SnippetListView(ListView): 11 | model = Snippet 12 | template_name = 'snippets/snippet_list.html' 13 | 14 | 15 | class SnippetDetailView(DetailView): 16 | model = Snippet 17 | template_name = 'snippets/snippet_detail.html' 18 | -------------------------------------------------------------------------------- /rest-tutorial-start/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "rest-tutorial.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /rest-tutorial-filtering/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "rest-tutorial.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /rest-tutorial-authentication/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "rest-tutorial.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sampleapp.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /rest-tutorial-start/snippets/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.5 on 2018-06-13 07:59 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Snippet', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('title', models.CharField(max_length=100)), 19 | ('body', models.TextField()), 20 | ('created', models.DateTimeField(auto_now_add=True)), 21 | ], 22 | ), 23 | ] 24 | -------------------------------------------------------------------------------- /rest-tutorial-filtering/snippets/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.5 on 2018-06-13 07:59 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Snippet', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('title', models.CharField(max_length=100)), 19 | ('body', models.TextField()), 20 | ('created', models.DateTimeField(auto_now_add=True)), 21 | ], 22 | ), 23 | ] 24 | -------------------------------------------------------------------------------- /rest-tutorial-authentication/snippets/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.5 on 2018-06-13 07:59 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Snippet', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('title', models.CharField(max_length=100)), 19 | ('body', models.TextField()), 20 | ('created', models.DateTimeField(auto_now_add=True)), 21 | ], 22 | ), 23 | ] 24 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.0.5 on 2018-06-13 07:59 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Snippet', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('title', models.CharField(max_length=100)), 19 | ('body', models.TextField()), 20 | ('created', models.DateTimeField(auto_now_add=True)), 21 | ], 22 | ), 23 | ] 24 | -------------------------------------------------------------------------------- /rest-tutorial-authentication/snippets/api/viewsets.py: -------------------------------------------------------------------------------- 1 | from snippets.models import Snippet 2 | from .serializers import SnippetSerializer 3 | from rest_framework import viewsets 4 | from rest_framework.decorators import action 5 | from rest_framework.response import Response 6 | from rest_framework.authentication import TokenAuthentication 7 | from rest_framework.permissions import IsAuthenticated 8 | 9 | 10 | class SnippetViewSet(viewsets.ModelViewSet): 11 | queryset = Snippet.objects.all() 12 | serializer_class = SnippetSerializer 13 | authentication_classes = (TokenAuthentication,) 14 | permission_classes = (IsAuthenticated,) 15 | 16 | @action(methods=['get'], detail=False) 17 | def newest(self, request): 18 | newest = self.get_queryset().order_by('created').last() 19 | serializer = self.get_serializer_class()(newest) 20 | return Response(serializer.data) 21 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/snippets/api/viewsets.py: -------------------------------------------------------------------------------- 1 | from snippets.models import Snippet 2 | from .serializers import SnippetSerializer 3 | from rest_framework import viewsets 4 | from rest_framework.decorators import action 5 | from rest_framework.response import Response 6 | 7 | 8 | # class SnippetViewSet(viewsets.ViewSet): 9 | # 10 | # # list, create, retrieve, update, partial_update, destroy 11 | # 12 | # def list(self, request): 13 | # queryset = Snippet.objects.all() 14 | # serializer = SnippetSerializer(queryset, many=True) 15 | # return Response(serializer.data) 16 | 17 | 18 | class SnippetViewSet(viewsets.ModelViewSet): 19 | queryset = Snippet.objects.all() 20 | serializer_class = SnippetSerializer 21 | 22 | @action(methods=['get'], detail=False) 23 | def newest(self, request): 24 | newest = self.get_queryset().order_by('created').last() 25 | serializer = self.get_serializer_class()(newest) 26 | return Response(serializer.data) 27 | -------------------------------------------------------------------------------- /rest-tutorial-filtering/snippets/api/viewsets.py: -------------------------------------------------------------------------------- 1 | from snippets.models import Snippet 2 | from .serializers import SnippetSerializer 3 | from rest_framework import viewsets 4 | from rest_framework.decorators import action 5 | from rest_framework.response import Response 6 | from rest_framework.authentication import TokenAuthentication 7 | from rest_framework.permissions import IsAuthenticated 8 | from django_filters import rest_framework as filters 9 | 10 | 11 | class SnippetFilter(filters.FilterSet): 12 | 13 | class Meta: 14 | model = Snippet 15 | fields = { 16 | 'title': ['icontains'], 17 | 'created': ['iexact', 'lte', 'gte'], 18 | } 19 | 20 | 21 | class SnippetViewSet(viewsets.ModelViewSet): 22 | queryset = Snippet.objects.all() 23 | serializer_class = SnippetSerializer 24 | filterset_class = SnippetFilter 25 | 26 | @action(methods=['get'], detail=False) 27 | def newest(self, request): 28 | newest = self.get_queryset().order_by('created').last() 29 | serializer = self.get_serializer_class()(newest) 30 | return Response(serializer.data) 31 | -------------------------------------------------------------------------------- /rest-tutorial-viewsets-and-routers/sampleapp/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for sampleapp project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.0.5. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.0/ref/settings/ 11 | """ 12 | 13 | import os 14 | 15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = '6vc%#!x-2s(a+i#w%vn+2am0_ug8=+sq8%k%-j8v*%oe(@v01$' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [] 29 | 30 | # Application definition 31 | 32 | INSTALLED_APPS = [ 33 | 'django.contrib.admin', 34 | 'django.contrib.auth', 35 | 'django.contrib.contenttypes', 36 | 'django.contrib.sessions', 37 | 'django.contrib.messages', 38 | 'django.contrib.staticfiles', 39 | 'snippets', 40 | 'rest_framework' 41 | ] 42 | 43 | MIDDLEWARE = [ 44 | 'django.middleware.security.SecurityMiddleware', 45 | 'django.contrib.sessions.middleware.SessionMiddleware', 46 | 'django.middleware.common.CommonMiddleware', 47 | 'django.middleware.csrf.CsrfViewMiddleware', 48 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 49 | 'django.contrib.messages.middleware.MessageMiddleware', 50 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 51 | ] 52 | 53 | ROOT_URLCONF = 'sampleapp.urls' 54 | 55 | TEMPLATES = [ 56 | { 57 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 58 | 'DIRS': [], 59 | 'APP_DIRS': True, 60 | 'OPTIONS': { 61 | 'context_processors': [ 62 | 'django.template.context_processors.debug', 63 | 'django.template.context_processors.request', 64 | 'django.contrib.auth.context_processors.auth', 65 | 'django.contrib.messages.context_processors.messages', 66 | ], 67 | }, 68 | }, 69 | ] 70 | 71 | WSGI_APPLICATION = 'sampleapp.wsgi.application' 72 | 73 | 74 | # Database 75 | # https://docs.djangoproject.com/en/2.0/ref/settings/#databases 76 | 77 | DATABASES = { 78 | 'default': { 79 | 'ENGINE': 'django.db.backends.sqlite3', 80 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 81 | } 82 | } 83 | 84 | 85 | # Password validation 86 | # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators 87 | 88 | AUTH_PASSWORD_VALIDATORS = [ 89 | { 90 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 91 | }, 92 | { 93 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 94 | }, 95 | { 96 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 97 | }, 98 | { 99 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 100 | }, 101 | ] 102 | 103 | 104 | # Internationalization 105 | # https://docs.djangoproject.com/en/2.0/topics/i18n/ 106 | 107 | LANGUAGE_CODE = 'en-us' 108 | 109 | TIME_ZONE = 'UTC' 110 | 111 | USE_I18N = True 112 | 113 | USE_L10N = True 114 | 115 | USE_TZ = True 116 | 117 | 118 | # Static files (CSS, JavaScript, Images) 119 | # https://docs.djangoproject.com/en/2.0/howto/static-files/ 120 | 121 | STATIC_URL = '/static/' 122 | -------------------------------------------------------------------------------- /rest-tutorial-start/rest-tutorial/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for rest-tutorial project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.0.5. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.0/ref/settings/ 11 | """ 12 | 13 | import os 14 | 15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = '6vc%#!x-2s(a+i#w%vn+2am0_ug8=+sq8%k%-j8v*%oe(@v01$' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [] 29 | 30 | 31 | # Application definition 32 | 33 | INSTALLED_APPS = [ 34 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | 'snippets' 41 | ] 42 | 43 | MIDDLEWARE = [ 44 | 'django.middleware.security.SecurityMiddleware', 45 | 'django.contrib.sessions.middleware.SessionMiddleware', 46 | 'django.middleware.common.CommonMiddleware', 47 | 'django.middleware.csrf.CsrfViewMiddleware', 48 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 49 | 'django.contrib.messages.middleware.MessageMiddleware', 50 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 51 | ] 52 | 53 | ROOT_URLCONF = 'rest-tutorial.urls' 54 | 55 | TEMPLATES = [ 56 | { 57 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 58 | 'DIRS': [os.path.join(BASE_DIR, 'rest-tutorial/templates')], 59 | 'APP_DIRS': True, 60 | 'OPTIONS': { 61 | 'context_processors': [ 62 | 'django.template.context_processors.debug', 63 | 'django.template.context_processors.request', 64 | 'django.contrib.auth.context_processors.auth', 65 | 'django.contrib.messages.context_processors.messages', 66 | ], 67 | }, 68 | }, 69 | ] 70 | 71 | WSGI_APPLICATION = 'rest-tutorial.wsgi.application' 72 | 73 | 74 | # Database 75 | # https://docs.djangoproject.com/en/2.0/ref/settings/#databases 76 | 77 | DATABASES = { 78 | 'default': { 79 | 'ENGINE': 'django.db.backends.sqlite3', 80 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 81 | } 82 | } 83 | 84 | 85 | # Password validation 86 | # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators 87 | 88 | AUTH_PASSWORD_VALIDATORS = [ 89 | { 90 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 91 | }, 92 | { 93 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 94 | }, 95 | { 96 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 97 | }, 98 | { 99 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 100 | }, 101 | ] 102 | 103 | 104 | # Internationalization 105 | # https://docs.djangoproject.com/en/2.0/topics/i18n/ 106 | 107 | LANGUAGE_CODE = 'en-us' 108 | 109 | TIME_ZONE = 'UTC' 110 | 111 | USE_I18N = True 112 | 113 | USE_L10N = True 114 | 115 | USE_TZ = True 116 | 117 | 118 | # Static files (CSS, JavaScript, Images) 119 | # https://docs.djangoproject.com/en/2.0/howto/static-files/ 120 | 121 | STATIC_URL = '/static/' 122 | -------------------------------------------------------------------------------- /rest-tutorial-filtering/rest-tutorial/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for rest-tutorial project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.0.5. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.0/ref/settings/ 11 | """ 12 | 13 | import os 14 | 15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = '6vc%#!x-2s(a+i#w%vn+2am0_ug8=+sq8%k%-j8v*%oe(@v01$' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [] 29 | 30 | 31 | # Application definition 32 | 33 | INSTALLED_APPS = [ 34 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | 'snippets', 41 | 'rest_framework', 42 | 'rest_framework.authtoken', 43 | 'django_filters' 44 | ] 45 | 46 | MIDDLEWARE = [ 47 | 'django.middleware.security.SecurityMiddleware', 48 | 'django.contrib.sessions.middleware.SessionMiddleware', 49 | 'django.middleware.common.CommonMiddleware', 50 | 'django.middleware.csrf.CsrfViewMiddleware', 51 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 52 | 'django.contrib.messages.middleware.MessageMiddleware', 53 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 54 | ] 55 | 56 | ROOT_URLCONF = 'rest-tutorial.urls' 57 | 58 | TEMPLATES = [ 59 | { 60 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 61 | 'DIRS': [os.path.join(BASE_DIR, 'rest-tutorial/templates')], 62 | 'APP_DIRS': True, 63 | 'OPTIONS': { 64 | 'context_processors': [ 65 | 'django.template.context_processors.debug', 66 | 'django.template.context_processors.request', 67 | 'django.contrib.auth.context_processors.auth', 68 | 'django.contrib.messages.context_processors.messages', 69 | ], 70 | }, 71 | }, 72 | ] 73 | 74 | WSGI_APPLICATION = 'rest-tutorial.wsgi.application' 75 | 76 | 77 | REST_FRAMEWORK = { 78 | 'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend',) 79 | } 80 | 81 | 82 | # Database 83 | # https://docs.djangoproject.com/en/2.0/ref/settings/#databases 84 | 85 | DATABASES = { 86 | 'default': { 87 | 'ENGINE': 'django.db.backends.sqlite3', 88 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 89 | } 90 | } 91 | 92 | 93 | # Password validation 94 | # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators 95 | 96 | AUTH_PASSWORD_VALIDATORS = [ 97 | { 98 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 99 | }, 100 | { 101 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 102 | }, 103 | { 104 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 105 | }, 106 | { 107 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 108 | }, 109 | ] 110 | 111 | 112 | # Internationalization 113 | # https://docs.djangoproject.com/en/2.0/topics/i18n/ 114 | 115 | LANGUAGE_CODE = 'en-us' 116 | 117 | TIME_ZONE = 'UTC' 118 | 119 | USE_I18N = True 120 | 121 | USE_L10N = True 122 | 123 | USE_TZ = True 124 | 125 | 126 | # Static files (CSS, JavaScript, Images) 127 | # https://docs.djangoproject.com/en/2.0/howto/static-files/ 128 | 129 | STATIC_URL = '/static/' 130 | -------------------------------------------------------------------------------- /rest-tutorial-authentication/rest-tutorial/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for rest-tutorial project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.0.5. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.0/ref/settings/ 11 | """ 12 | 13 | import os 14 | 15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = '6vc%#!x-2s(a+i#w%vn+2am0_ug8=+sq8%k%-j8v*%oe(@v01$' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [] 29 | 30 | 31 | # Application definition 32 | 33 | INSTALLED_APPS = [ 34 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | 'snippets', 41 | 'rest_framework', 42 | 'rest_framework.authtoken' 43 | ] 44 | 45 | MIDDLEWARE = [ 46 | 'django.middleware.security.SecurityMiddleware', 47 | 'django.contrib.sessions.middleware.SessionMiddleware', 48 | 'django.middleware.common.CommonMiddleware', 49 | 'django.middleware.csrf.CsrfViewMiddleware', 50 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 51 | 'django.contrib.messages.middleware.MessageMiddleware', 52 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 53 | ] 54 | 55 | ROOT_URLCONF = 'rest-tutorial.urls' 56 | 57 | TEMPLATES = [ 58 | { 59 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 60 | 'DIRS': [os.path.join(BASE_DIR, 'rest-tutorial/templates')], 61 | 'APP_DIRS': True, 62 | 'OPTIONS': { 63 | 'context_processors': [ 64 | 'django.template.context_processors.debug', 65 | 'django.template.context_processors.request', 66 | 'django.contrib.auth.context_processors.auth', 67 | 'django.contrib.messages.context_processors.messages', 68 | ], 69 | }, 70 | }, 71 | ] 72 | 73 | WSGI_APPLICATION = 'rest-tutorial.wsgi.application' 74 | 75 | 76 | REST_FRAMEWORK = { 77 | 'DEFAULT_AUTHENTICATION_CLASSES': ( 78 | 'rest_framework.authentication.TokenAuthentication', 79 | ), 80 | 'DEFAULT_PERMISSION_CLASSES': ( 81 | 'rest_framework.permissions.IsAuthenticated', 82 | ), 83 | } 84 | 85 | 86 | # Database 87 | # https://docs.djangoproject.com/en/2.0/ref/settings/#databases 88 | 89 | DATABASES = { 90 | 'default': { 91 | 'ENGINE': 'django.db.backends.sqlite3', 92 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 93 | } 94 | } 95 | 96 | 97 | # Password validation 98 | # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators 99 | 100 | AUTH_PASSWORD_VALIDATORS = [ 101 | { 102 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 103 | }, 104 | { 105 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 106 | }, 107 | { 108 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 109 | }, 110 | { 111 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 112 | }, 113 | ] 114 | 115 | 116 | # Internationalization 117 | # https://docs.djangoproject.com/en/2.0/topics/i18n/ 118 | 119 | LANGUAGE_CODE = 'en-us' 120 | 121 | TIME_ZONE = 'UTC' 122 | 123 | USE_I18N = True 124 | 125 | USE_L10N = True 126 | 127 | USE_TZ = True 128 | 129 | 130 | # Static files (CSS, JavaScript, Images) 131 | # https://docs.djangoproject.com/en/2.0/howto/static-files/ 132 | 133 | STATIC_URL = '/static/' 134 | --------------------------------------------------------------------------------