Skip to content

Instantly share code, notes, and snippets.

View chapimenge3's full-sized avatar
👨‍💻
Try not to fail and if you do Try not to break at the same time.

Temkin Mengsitu chapimenge3

👨‍💻
Try not to fail and if you do Try not to break at the same time.
View GitHub Profile
# 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
from django.shortcuts import render
# restframewok
from rest_framework import viewsets
# Project
from Todo.models import Todo
from Todo.serializers import TodoSerializer
from django.contrib import admin
from django.urls import path, include # new
urlpatterns = [
path('', include('Todo.urls')), # new
path('admin/', admin.site.urls),
]
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()
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 = {
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
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
service: Todo
frameworkVersion: '3'
# new
custom:
tableName: 'todo-table-${self:provider.stage}'
provider:
name: aws
runtime: python3.8
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 goes to Below the create_todo function
'''
def list_todo(event, context):
'''
List Todo Application in Dynamo DB
Params:
event: API Gateway Event