Виконайте всі кроки по порядку перед першим деплоєм (інструкція відносно загальна, тому можуть бути додаткові кроки)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from rest_framework.viewsets import ModelViewSet | |
| from rest_framework.permissions import AllowAny | |
| from rest_framework.response import Response | |
| from django.core.cache import cache | |
| from .models import Artist, Album, Track, Genre | |
| from .serializers import ( | |
| ArtistSerializer, | |
| AlbumReadSerializer, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import posixpath | |
| BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| SECRET_KEY = 'b2ea905d-f402-441b-b8e9-fbe0b3899a92' | |
| DEBUG = True | |
| ALLOWED_HOSTS = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| api / views.py: | |
| from rest_framework.viewsets import ModelViewSet | |
| from rest_framework.permissions import IsAdminUser | |
| from .models import Artist, Album, Track, Genre | |
| from .serializers import ( | |
| ArtistSerializer, | |
| AlbumReadSerializer, | |
| AlbumWriteSerializer, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| правки треба зробити в 2 файлах проєкту https://github.com/sunmeat/django_drf3 | |
| Rest / api / admin.py: | |
| # python manage.py createsuperuser | |
| # http://localhost:63786/admin/ | |
| from django.contrib import admin | |
| from .models import Artist, Album, Track, Genre |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- | |
| 1) pip install django-cors-headers | |
| 2) INSTALLED_APPS = [ | |
| 'corsheaders', | |
| 3) MIDDLEWARE = [ | |
| 'corsheaders.middleware.CorsMiddleware', | |
| 4) CORS_ALLOW_ALL_ORIGINS = True в кінець settings.py | |
| 5) змінити порт на 503 рядку | |
| --> |
Переклад ключових тез статті з restfulapi.net
REST (Representational State Transfer) — архітектурний стиль для побудови мережевих застосунків, запропонований Роєм Філдінгом у 2000 році. REST — не протокол і не специфікація, а набір архітектурних обмежень. HTTP-API не є автоматично RESTful — важливо дотримуватись принципів.