This file contains 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
# Restframework | |
from django.db.models import fields | |
from rest_framework import serializers | |
# Project | |
from Todo.models import Todo | |
class TodoSerializer(serializers.ModelSerializer): | |
class Meta: | |
model = Todo |
This file contains 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 django.shortcuts import render | |
# restframewok | |
from rest_framework import viewsets | |
# Project | |
from Todo.models import Todo | |
from Todo.serializers import TodoSerializer | |
This file contains 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 django.contrib import admin | |
from django.urls import path, include # new | |
urlpatterns = [ | |
path('', include('Todo.urls')), # new | |
path('admin/', admin.site.urls), | |
] |
This file contains 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 django.urls import path, include | |
from rest_framework import routers | |
# restframework | |
from rest_framework.routers import DefaultRouter | |
# Project | |
from Todo.views import TodoViewset | |
router = DefaultRouter() |
This file contains 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
class UserSerializer(ModelSerializer): | |
password = CharField(style={'input_type': 'password'}, write_only=True) | |
password2 = CharField(style={'input_type': 'password'}, write_only=True) | |
class Meta: | |
model = get_user_model() | |
fields = ('id', 'username', 'password', 'password2', | |
'email', 'first_name', 'last_name',) | |
extra_kwargs = { |
This file contains 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 django.shortcuts import render, get_object_or_404 | |
from django.contrib.auth import get_user_model | |
# 3rd party imports | |
from rest_framework import viewsets, permissions, response, status | |
from rest_framework.authtoken.models import Token | |
from rest_framework.views import APIView | |
# My app imports | |
from accounts.serializers import UserSerializer |
This file contains 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
service: Todo | |
frameworkVersion: '3' | |
provider: | |
name: aws | |
runtime: python3.8 | |
# Totally optional, but it's a good idea to set this | |
stage: dev | |
profile: default # if you are working with different AWS account |
This file contains 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
service: Todo | |
frameworkVersion: '3' | |
# new | |
custom: | |
tableName: 'todo-table-${self:provider.stage}' | |
provider: | |
name: aws | |
runtime: python3.8 |
This file contains 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 boto3 | |
import json | |
TODO_TABLE = os.getenv('TODO_TABLE') | |
dynamodb = boto3.resource('dynamodb') | |
table = dynamodb.Table(TODO_TABLE) | |
def create_todo(event, context): |
This file contains 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
''' | |
this goes to Below the create_todo function | |
''' | |
def list_todo(event, context): | |
''' | |
List Todo Application in Dynamo DB | |
Params: | |
event: API Gateway Event |
OlderNewer