├── README.md ├── api ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-38.pyc │ ├── admin.cpython-38.pyc │ ├── apps.cpython-38.pyc │ ├── models.cpython-38.pyc │ ├── serializers.cpython-38.pyc │ ├── urls.cpython-38.pyc │ └── views.cpython-38.pyc ├── admin.py ├── apps.py ├── migrations │ ├── 0001_initial.py │ ├── __init__.py │ └── __pycache__ │ │ ├── 0001_initial.cpython-38.pyc │ │ └── __init__.cpython-38.pyc ├── models.py ├── serializers.py ├── tests.py ├── urls.py └── views.py ├── db.sqlite3 ├── manage.py ├── requirements.txt └── todo_drf ├── __init__.py ├── __pycache__ ├── __init__.cpython-38.pyc ├── settings.cpython-38.pyc ├── urls.cpython-38.pyc └── wsgi.cpython-38.pyc ├── asgi.py ├── settings.py ├── urls.py └── wsgi.py /README.md: -------------------------------------------------------------------------------- 1 | # ToDo 2 | `https://github.com/rkshaon/react_django_todo` 3 | 4 | ## Requirements 5 | 1. You need to install Python (`https://www.python.org/downloads/`) 6 | 3. You need to install node (`https://nodejs.org/en/download/`) 7 | 4. You need to install npm (`https://www.npmjs.com/get-npm`) 8 | 5. You need to install npx (`https://www.npmjs.com/package/npx`) 9 | 10 | ## How to run? 11 | Open CLI and type mkdir project and hit enter\ 12 | $ cd project\ 13 | $ git clone `https://github.com/rkshaon/react_django_todo.git`\ 14 | $ pip install -r requirements.txt\ 15 | $ cd react_tours\ 16 | $ npm run build\ 17 | $ cd ..\ 18 | $ python manage.py runserver\ 19 | then open the browser and hit `http://127.0.0.1:8000/` 20 | 21 | ### Front End 22 | ReactJS 23 | 24 | ### Back End 25 | Django Rest Framework 26 | -------------------------------------------------------------------------------- /api/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkshaon/rest_django_todo/5c4d997853dc3aa02fc8b823f5a12e13f483a6db/api/__init__.py -------------------------------------------------------------------------------- /api/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkshaon/rest_django_todo/5c4d997853dc3aa02fc8b823f5a12e13f483a6db/api/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /api/__pycache__/admin.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkshaon/rest_django_todo/5c4d997853dc3aa02fc8b823f5a12e13f483a6db/api/__pycache__/admin.cpython-38.pyc -------------------------------------------------------------------------------- /api/__pycache__/apps.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkshaon/rest_django_todo/5c4d997853dc3aa02fc8b823f5a12e13f483a6db/api/__pycache__/apps.cpython-38.pyc -------------------------------------------------------------------------------- /api/__pycache__/models.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkshaon/rest_django_todo/5c4d997853dc3aa02fc8b823f5a12e13f483a6db/api/__pycache__/models.cpython-38.pyc -------------------------------------------------------------------------------- /api/__pycache__/serializers.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkshaon/rest_django_todo/5c4d997853dc3aa02fc8b823f5a12e13f483a6db/api/__pycache__/serializers.cpython-38.pyc -------------------------------------------------------------------------------- /api/__pycache__/urls.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkshaon/rest_django_todo/5c4d997853dc3aa02fc8b823f5a12e13f483a6db/api/__pycache__/urls.cpython-38.pyc -------------------------------------------------------------------------------- /api/__pycache__/views.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkshaon/rest_django_todo/5c4d997853dc3aa02fc8b823f5a12e13f483a6db/api/__pycache__/views.cpython-38.pyc -------------------------------------------------------------------------------- /api/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | 5 | from .models import Task 6 | 7 | admin.site.register(Task) -------------------------------------------------------------------------------- /api/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class ApiConfig(AppConfig): 5 | name = 'api' 6 | -------------------------------------------------------------------------------- /api/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.0.2 on 2020-02-11 02:18 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='Task', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('title', models.CharField(max_length=200)), 19 | ('completed', models.BooleanField(blank=True, default=False, null=True)), 20 | ], 21 | ), 22 | ] 23 | -------------------------------------------------------------------------------- /api/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkshaon/rest_django_todo/5c4d997853dc3aa02fc8b823f5a12e13f483a6db/api/migrations/__init__.py -------------------------------------------------------------------------------- /api/migrations/__pycache__/0001_initial.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkshaon/rest_django_todo/5c4d997853dc3aa02fc8b823f5a12e13f483a6db/api/migrations/__pycache__/0001_initial.cpython-38.pyc -------------------------------------------------------------------------------- /api/migrations/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkshaon/rest_django_todo/5c4d997853dc3aa02fc8b823f5a12e13f483a6db/api/migrations/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /api/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | class Task(models.Model): 4 | title = models.CharField(max_length=200) 5 | completed = models.BooleanField(default=False, blank=True, null=True) 6 | 7 | def __str__(self): 8 | return self.title 9 | -------------------------------------------------------------------------------- /api/serializers.py: -------------------------------------------------------------------------------- 1 | from rest_framework import serializers 2 | from .models import Task 3 | 4 | class TaskSerializer(serializers.ModelSerializer): 5 | class Meta: 6 | model = Task 7 | fields ='__all__' 8 | -------------------------------------------------------------------------------- /api/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /api/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | from . import views 3 | 4 | urlpatterns = [ 5 | path('', views.apiOverview, name="api-overview"), 6 | path('task-list/', views.taskList, name="task-list"), 7 | path('task-detail//', views.taskDetail, name="task-detail"), 8 | path('task-create/', views.taskCreate, name="task-create"), 9 | path('task-update//', views.taskUpdate, name="task-update"), 10 | path('task-delete//', views.taskDelete, name="task-delete"), 11 | ] 12 | -------------------------------------------------------------------------------- /api/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.http import JsonResponse 3 | from rest_framework.decorators import api_view 4 | from rest_framework.response import Response 5 | from .serializers import TaskSerializer 6 | from .models import Task 7 | 8 | @api_view(['GET']) 9 | def apiOverview(request): 10 | api_urls = { 11 | 'List':'/task-list/', 12 | 'Detail View':'/task-detail//', 13 | 'Create':'/task-create/', 14 | 'Update':'/task-update//', 15 | 'Delete':'/task-delete//', 16 | } 17 | return Response(api_urls) 18 | 19 | @api_view(['GET']) 20 | def taskList(request): 21 | tasks = Task.objects.all().order_by('-id') 22 | serializer = TaskSerializer(tasks, many=True) 23 | return Response(serializer.data) 24 | 25 | @api_view(['GET']) 26 | def taskDetail(request, pk): 27 | tasks = Task.objects.get(id=pk) 28 | serializer = TaskSerializer(tasks, many=False) 29 | return Response(serializer.data) 30 | 31 | @api_view(['POST']) 32 | def taskCreate(request): 33 | serializer = TaskSerializer(data=request.data) 34 | if serializer.is_valid(): 35 | serializer.save() 36 | return Response(serializer.data) 37 | 38 | @api_view(['POST']) 39 | def taskUpdate(request, pk): 40 | task = Task.objects.get(id=pk) 41 | serializer = TaskSerializer(instance=task, data=request.data) 42 | if serializer.is_valid(): 43 | serializer.save() 44 | return Response(serializer.data) 45 | 46 | 47 | @api_view(['DELETE']) 48 | def taskDelete(request, pk): 49 | task = Task.objects.get(id=pk) 50 | task.delete() 51 | return Response('Item succsesfully delete!') 52 | -------------------------------------------------------------------------------- /db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkshaon/rest_django_todo/5c4d997853dc3aa02fc8b823f5a12e13f483a6db/db.sqlite3 -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_drf.settings') 9 | try: 10 | from django.core.management import execute_from_command_line 11 | except ImportError as exc: 12 | raise ImportError( 13 | "Couldn't import Django. Are you sure it's installed and " 14 | "available on your PYTHONPATH environment variable? Did you " 15 | "forget to activate a virtual environment?" 16 | ) from exc 17 | execute_from_command_line(sys.argv) 18 | 19 | 20 | if __name__ == '__main__': 21 | main() 22 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | argon2-cffi==20.1.0 2 | asgiref==3.2.3 3 | astroid==2.4.2 4 | bcrypt==3.1.7 5 | certifi==2020.6.20 6 | cffi==1.14.0 7 | colorama==0.4.3 8 | Django==3.0.3 9 | django-cors-headers==3.4.0 10 | djangorestframework==3.11.0 11 | Faker==4.1.1 12 | isort==4.3.21 13 | lazy-object-proxy==1.4.3 14 | mccabe==0.6.1 15 | Pillow==7.2.0 16 | pycparser==2.20 17 | pylint==2.5.3 18 | python-dateutil==2.8.1 19 | pytz==2019.3 20 | six==1.15.0 21 | sqlparse==0.3.0 22 | text-unidecode==1.3 23 | toml==0.10.1 24 | wincertstore==0.2 25 | wrapt==1.12.1 26 | -------------------------------------------------------------------------------- /todo_drf/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkshaon/rest_django_todo/5c4d997853dc3aa02fc8b823f5a12e13f483a6db/todo_drf/__init__.py -------------------------------------------------------------------------------- /todo_drf/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkshaon/rest_django_todo/5c4d997853dc3aa02fc8b823f5a12e13f483a6db/todo_drf/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /todo_drf/__pycache__/settings.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkshaon/rest_django_todo/5c4d997853dc3aa02fc8b823f5a12e13f483a6db/todo_drf/__pycache__/settings.cpython-38.pyc -------------------------------------------------------------------------------- /todo_drf/__pycache__/urls.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkshaon/rest_django_todo/5c4d997853dc3aa02fc8b823f5a12e13f483a6db/todo_drf/__pycache__/urls.cpython-38.pyc -------------------------------------------------------------------------------- /todo_drf/__pycache__/wsgi.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rkshaon/rest_django_todo/5c4d997853dc3aa02fc8b823f5a12e13f483a6db/todo_drf/__pycache__/wsgi.cpython-38.pyc -------------------------------------------------------------------------------- /todo_drf/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for todo_drf project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_drf.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /todo_drf/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for todo_drf project. 3 | 4 | Generated by 'django-admin startproject' using Django 3.0.2. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/3.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 | REACT_TEMP_DIR = os.path.join(BASE_DIR, 'todo_react/build') 18 | REACT_STATIC_DIR = os.path.join(BASE_DIR, 'todo_react/build/static') 19 | 20 | # Quick-start development settings - unsuitable for production 21 | # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ 22 | 23 | # SECURITY WARNING: keep the secret key used in production secret! 24 | SECRET_KEY = '-c1cg^-j%2l-e_-(0+ey030&yvz@^k$x@%w0pwgm#of%)qrqe+' 25 | 26 | # SECURITY WARNING: don't run with debug turned on in production! 27 | DEBUG = True 28 | 29 | ALLOWED_HOSTS = [] 30 | 31 | 32 | # Application definition 33 | 34 | INSTALLED_APPS = [ 35 | 'django.contrib.admin', 36 | 'django.contrib.auth', 37 | 'django.contrib.contenttypes', 38 | 'django.contrib.sessions', 39 | 'django.contrib.messages', 40 | 'django.contrib.staticfiles', 41 | 'api', 42 | 'rest_framework', 43 | 'corsheaders', 44 | ] 45 | 46 | MIDDLEWARE = [ 47 | 'corsheaders.middleware.CorsMiddleware', 48 | 'django.middleware.security.SecurityMiddleware', 49 | 'django.contrib.sessions.middleware.SessionMiddleware', 50 | 'django.middleware.common.CommonMiddleware', 51 | 'django.middleware.csrf.CsrfViewMiddleware', 52 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 53 | 'django.contrib.messages.middleware.MessageMiddleware', 54 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 55 | ] 56 | 57 | ROOT_URLCONF = 'todo_drf.urls' 58 | 59 | TEMPLATES = [ 60 | { 61 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 62 | 'DIRS': [ 63 | REACT_TEMP_DIR, 64 | ], 65 | 'APP_DIRS': True, 66 | 'OPTIONS': { 67 | 'context_processors': [ 68 | 'django.template.context_processors.debug', 69 | 'django.template.context_processors.request', 70 | 'django.contrib.auth.context_processors.auth', 71 | 'django.contrib.messages.context_processors.messages', 72 | ], 73 | }, 74 | }, 75 | ] 76 | 77 | WSGI_APPLICATION = 'todo_drf.wsgi.application' 78 | 79 | 80 | # Database 81 | # https://docs.djangoproject.com/en/3.0/ref/settings/#databases 82 | 83 | DATABASES = { 84 | 'default': { 85 | 'ENGINE': 'django.db.backends.sqlite3', 86 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 87 | } 88 | } 89 | 90 | 91 | # Password validation 92 | # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators 93 | 94 | AUTH_PASSWORD_VALIDATORS = [ 95 | { 96 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 97 | }, 98 | { 99 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 100 | }, 101 | { 102 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 103 | }, 104 | { 105 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 106 | }, 107 | ] 108 | 109 | 110 | # Internationalization 111 | # https://docs.djangoproject.com/en/3.0/topics/i18n/ 112 | 113 | LANGUAGE_CODE = 'en-us' 114 | 115 | TIME_ZONE = 'UTC' 116 | 117 | USE_I18N = True 118 | 119 | USE_L10N = True 120 | 121 | USE_TZ = True 122 | 123 | 124 | # Static files (CSS, JavaScript, Images) 125 | # https://docs.djangoproject.com/en/3.0/howto/static-files/ 126 | 127 | STATIC_URL = '/static/' 128 | 129 | STATICFILES_DIRS = [ 130 | REACT_STATIC_DIR, 131 | ] 132 | 133 | CORS_ORIGIN_WHITELIST = [ 134 | "http://localhost:3000", 135 | ] 136 | -------------------------------------------------------------------------------- /todo_drf/urls.py: -------------------------------------------------------------------------------- 1 | """todo_drf URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/3.0/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path, include 18 | from django.views.generic import TemplateView 19 | 20 | urlpatterns = [ 21 | path('admin/', admin.site.urls), 22 | path('api/', include('api.urls')), 23 | path('', TemplateView.as_view(template_name='index.html')), 24 | ] 25 | -------------------------------------------------------------------------------- /todo_drf/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for todo_drf 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/3.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', 'todo_drf.settings') 15 | 16 | application = get_wsgi_application() 17 | --------------------------------------------------------------------------------