Todo app
120 |-
130 | {this.renderItems()}
131 |
├── .gitignore
├── LICENSE
├── Pipfile
├── Pipfile.lock
├── README.md
├── backend
├── backend
│ ├── __init__.py
│ ├── asgi.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── manage.py
└── todo
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── models.py
│ ├── serializers.py
│ ├── tests.py
│ └── views.py
└── frontend
├── README.md
├── package.json
├── public
├── favicon.ico
├── index.html
└── manifest.json
├── src
├── App.css
├── App.js
├── App.test.js
├── components
│ └── Modal.js
├── index.css
├── index.js
├── logo.svg
└── serviceWorker.js
└── yarn.lock
/.gitignore:
--------------------------------------------------------------------------------
1 | migrations
2 | __pycache__
3 | db.sqlite3
4 | node_modules
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Mohammad Dori
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Pipfile:
--------------------------------------------------------------------------------
1 | [[source]]
2 | url = "https://pypi.org/simple"
3 | verify_ssl = true
4 | name = "pypi"
5 |
6 | [packages]
7 | django = "*"
8 | djangorestframework = "*"
9 | django-cors-headers = "*"
10 |
11 | [dev-packages]
12 |
13 | [requires]
14 | python_version = "3.8"
15 |
--------------------------------------------------------------------------------
/Pipfile.lock:
--------------------------------------------------------------------------------
1 | {
2 | "_meta": {
3 | "hash": {
4 | "sha256": "981a87d642bb51e35e0c114707a76c8c4b7ba9dcd146a62ea7d0992cb27c8c6b"
5 | },
6 | "pipfile-spec": 6,
7 | "requires": {
8 | "python_version": "3.8"
9 | },
10 | "sources": [
11 | {
12 | "name": "pypi",
13 | "url": "https://pypi.org/simple",
14 | "verify_ssl": true
15 | }
16 | ]
17 | },
18 | "default": {
19 | "asgiref": {
20 | "hashes": [
21 | "sha256:2f8abc20f7248433085eda803936d98992f1343ddb022065779f37c5da0181d0",
22 | "sha256:88d59c13d634dcffe0510be048210188edd79aeccb6a6c9028cdad6f31d730a9"
23 | ],
24 | "markers": "python_version >= '3.7'",
25 | "version": "==3.5.0"
26 | },
27 | "backports.zoneinfo": {
28 | "hashes": [
29 | "sha256:17746bd546106fa389c51dbea67c8b7c8f0d14b5526a579ca6ccf5ed72c526cf",
30 | "sha256:1b13e654a55cd45672cb54ed12148cd33628f672548f373963b0bff67b217328",
31 | "sha256:1c5742112073a563c81f786e77514969acb58649bcdf6cdf0b4ed31a348d4546",
32 | "sha256:4a0f800587060bf8880f954dbef70de6c11bbe59c673c3d818921f042f9954a6",
33 | "sha256:5c144945a7752ca544b4b78c8c41544cdfaf9786f25fe5ffb10e838e19a27570",
34 | "sha256:7b0a64cda4145548fed9efc10322770f929b944ce5cee6c0dfe0c87bf4c0c8c9",
35 | "sha256:8439c030a11780786a2002261569bdf362264f605dfa4d65090b64b05c9f79a7",
36 | "sha256:8961c0f32cd0336fb8e8ead11a1f8cd99ec07145ec2931122faaac1c8f7fd987",
37 | "sha256:89a48c0d158a3cc3f654da4c2de1ceba85263fafb861b98b59040a5086259722",
38 | "sha256:a76b38c52400b762e48131494ba26be363491ac4f9a04c1b7e92483d169f6582",
39 | "sha256:da6013fd84a690242c310d77ddb8441a559e9cb3d3d59ebac9aca1a57b2e18bc",
40 | "sha256:e55b384612d93be96506932a786bbcde5a2db7a9e6a4bb4bffe8b733f5b9036b",
41 | "sha256:e81b76cace8eda1fca50e345242ba977f9be6ae3945af8d46326d776b4cf78d1",
42 | "sha256:e8236383a20872c0cdf5a62b554b27538db7fa1bbec52429d8d106effbaeca08",
43 | "sha256:f04e857b59d9d1ccc39ce2da1021d196e47234873820cbeaad210724b1ee28ac",
44 | "sha256:fadbfe37f74051d024037f223b8e001611eac868b5c5b06144ef4d8b799862f2"
45 | ],
46 | "markers": "python_version < '3.9'",
47 | "version": "==0.2.1"
48 | },
49 | "django": {
50 | "hashes": [
51 | "sha256:1239218849e922033a35d2a2f777cb8bee18bd725416744074f455f34ff50d0c",
52 | "sha256:77ff2e7050e3324c9b67e29b6707754566f58514112a9ac73310f60cd5261930"
53 | ],
54 | "index": "pypi",
55 | "version": "==4.0.3"
56 | },
57 | "django-cors-headers": {
58 | "hashes": [
59 | "sha256:a22be2befd4069c4fc174f11cf067351df5c061a3a5f94a01650b4e928b0372b",
60 | "sha256:eb98389bf7a2afc5d374806af4a9149697e3a6955b5a2dc2bf049f7d33647456"
61 | ],
62 | "index": "pypi",
63 | "version": "==3.11.0"
64 | },
65 | "djangorestframework": {
66 | "hashes": [
67 | "sha256:0c33407ce23acc68eca2a6e46424b008c9c02eceb8cf18581921d0092bc1f2ee",
68 | "sha256:24c4bf58ed7e85d1fe4ba250ab2da926d263cd57d64b03e8dcef0ac683f8b1aa"
69 | ],
70 | "index": "pypi",
71 | "version": "==3.13.1"
72 | },
73 | "pytz": {
74 | "hashes": [
75 | "sha256:3672058bc3453457b622aab7a1c3bfd5ab0bdae451512f6cf25f64ed37f5b87c",
76 | "sha256:acad2d8b20a1af07d4e4c9d2e9285c5ed9104354062f275f3fcd88dcef4f1326"
77 | ],
78 | "version": "==2021.3"
79 | },
80 | "sqlparse": {
81 | "hashes": [
82 | "sha256:0c00730c74263a94e5a9919ade150dfc3b19c574389985446148402998287dae",
83 | "sha256:48719e356bb8b42991bdbb1e8b83223757b93789c00910a616a071910ca4a64d"
84 | ],
85 | "markers": "python_version >= '3.5'",
86 | "version": "==0.4.2"
87 | }
88 | },
89 | "develop": {}
90 | }
91 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Django Todo React
2 |
3 | Create todo app with Django and React.
4 |
5 | #
6 |
7 | ## Tools
8 |
9 | - Django 4
10 | - React Js
11 | - Python 3
12 |
13 | #
14 |
15 | # How to Run Project
16 |
17 | ## Download Codes
18 |
19 | ```
20 | git clone https://github.com/dori-dev/django-todo-react.git
21 | ```
22 |
23 | ```
24 | cd django-todo-react
25 | ```
26 |
27 | ## Install Backend Requirements
28 |
29 | ```
30 | pip install pipenv
31 | ```
32 |
33 | ```
34 | pipenv shell
35 | ```
36 |
37 | ```
38 | pipenv install
39 | ```
40 |
41 | ## Install Frontend Dependencies
42 |
43 | ```
44 | cd frontend
45 | ```
46 |
47 | ```
48 | npm install
49 | npm audit
50 | ```
51 |
52 | ## Migrate Backend Models
53 |
54 | ```
55 | cd ..
56 | cd backend
57 | ```
58 |
59 | ```
60 | python manage.py makemigrations todo
61 | ```
62 |
63 | ```
64 | python manage.py migrate
65 | ```
66 |
67 | ## Add Super User
68 |
69 | ```
70 | python manage.py createsuperuser
71 | ```
72 |
73 | ## Run Django Server
74 |
75 | ```
76 | python manage.py runserver
77 | ```
78 |
79 | ## Run FrontEnd
80 |
81 | open new terminal in `frontend` directory and run this command.
82 |
83 | ```
84 | npm start
85 | ```
86 |
87 | ## Open On Browser
88 |
89 | App Page
90 | [localhost:3000](http://localhost:3000/)
91 |
92 | Django Admin Page
93 | [127.0.0.1:8000/admin](http://127.0.0.1:8000/admin)
94 |
95 | #
96 |
97 | ## Links
98 |
99 | Download Source Code: [Click Here](https://github.com/dori-dev/django-todo-react/archive/refs/heads/master.zip)
100 |
101 | My Github Account: [Click Here](https://github.com/dori-dev/)
102 |
--------------------------------------------------------------------------------
/backend/backend/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dori-dev/django-todo-react/2116629f4f4ba060b7057a6cb800e1eae058e0f9/backend/backend/__init__.py
--------------------------------------------------------------------------------
/backend/backend/asgi.py:
--------------------------------------------------------------------------------
1 | """
2 | ASGI config for backend 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.2/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', 'backend.settings')
15 |
16 | application = get_asgi_application()
17 |
--------------------------------------------------------------------------------
/backend/backend/settings.py:
--------------------------------------------------------------------------------
1 | """
2 | Django settings for backend project.
3 |
4 | Generated by 'django-admin startproject' using Django 3.2.9.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.2/topics/settings/
8 |
9 | For the full list of settings and their values, see
10 | https://docs.djangoproject.com/en/3.2/ref/settings/
11 | """
12 |
13 | from pathlib import Path
14 |
15 | # Build paths inside the project like this: BASE_DIR / 'subdir'.
16 | BASE_DIR = Path(__file__).resolve().parent.parent
17 |
18 |
19 | # Quick-start development settings - unsuitable for production
20 | # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
21 |
22 | # SECURITY WARNING: keep the secret key used in production secret!
23 | SECRET_KEY = 'django-insecure-+14$ncew!$k1v@a$+va7ngm#!#2!+*+!=6)n1bsv(sd4#i^$+m'
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 | 'corsheaders',
41 | 'rest_framework',
42 | 'todo',
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 | 'corsheaders.middleware.CorsMiddleware',
54 | ]
55 |
56 | ROOT_URLCONF = 'backend.urls'
57 |
58 | TEMPLATES = [
59 | {
60 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
61 | 'DIRS': [],
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 = 'backend.wsgi.application'
75 |
76 |
77 | # Database
78 | # https://docs.djangoproject.com/en/3.2/ref/settings/#databases
79 |
80 | DATABASES = {
81 | 'default': {
82 | 'ENGINE': 'django.db.backends.sqlite3',
83 | 'NAME': BASE_DIR / 'db.sqlite3',
84 | }
85 | }
86 |
87 |
88 | # Password validation
89 | # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
90 |
91 | AUTH_PASSWORD_VALIDATORS = [
92 | {
93 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
94 | },
95 | {
96 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
97 | },
98 | {
99 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
100 | },
101 | {
102 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
103 | },
104 | ]
105 |
106 |
107 | # Internationalization
108 | # https://docs.djangoproject.com/en/3.2/topics/i18n/
109 |
110 | LANGUAGE_CODE = 'en-us'
111 |
112 | TIME_ZONE = 'UTC'
113 |
114 | USE_I18N = True
115 |
116 | USE_L10N = True
117 |
118 | USE_TZ = True
119 |
120 |
121 | # Static files (CSS, JavaScript, Images)
122 | # https://docs.djangoproject.com/en/3.2/howto/static-files/
123 |
124 | STATIC_URL = '/static/'
125 |
126 | # Default primary key field type
127 | # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
128 |
129 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
130 |
131 | CORS_ORIGIN_WHITELIST = [
132 | 'http://localhost:3000'
133 | ]
134 |
--------------------------------------------------------------------------------
/backend/backend/urls.py:
--------------------------------------------------------------------------------
1 | """backend URL Configuration
2 | """
3 | from django.contrib import admin
4 | from django.urls import path, include
5 | from rest_framework import routers
6 | from todo import views
7 |
8 | router = routers.DefaultRouter()
9 | router.register(r'todos', views.TodoView, 'todo')
10 |
11 | urlpatterns = [
12 | path('admin/', admin.site.urls),
13 | path('api/', include(router.urls)),
14 | ]
15 |
--------------------------------------------------------------------------------
/backend/backend/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for backend 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.2/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', 'backend.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/backend/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 | """Run administrative tasks."""
9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')
10 | try:
11 | from django.core.management import execute_from_command_line
12 | except ImportError as exc:
13 | raise ImportError(
14 | "Couldn't import Django. Are you sure it's installed and "
15 | "available on your PYTHONPATH environment variable? Did you "
16 | "forget to activate a virtual environment?"
17 | ) from exc
18 | execute_from_command_line(sys.argv)
19 |
20 |
21 | if __name__ == '__main__':
22 | main()
23 |
--------------------------------------------------------------------------------
/backend/todo/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dori-dev/django-todo-react/2116629f4f4ba060b7057a6cb800e1eae058e0f9/backend/todo/__init__.py
--------------------------------------------------------------------------------
/backend/todo/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from .models import Todo
3 |
4 |
5 | class TodoAdmin(admin.ModelAdmin):
6 | list_display = ('title', 'description', 'completed')
7 |
8 |
9 | admin.site.register(Todo, TodoAdmin)
10 |
--------------------------------------------------------------------------------
/backend/todo/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class TodoConfig(AppConfig):
5 | default_auto_field = 'django.db.models.BigAutoField'
6 | name = 'todo'
7 |
--------------------------------------------------------------------------------
/backend/todo/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 |
4 | class Todo(models.Model):
5 | title = models.CharField(max_length=120)
6 | description = models.TextField()
7 | completed = models.BooleanField(default=False)
8 |
9 | def __str__(self) -> str:
10 | return self.title
11 |
--------------------------------------------------------------------------------
/backend/todo/serializers.py:
--------------------------------------------------------------------------------
1 | """serializers
2 | """
3 |
4 | from rest_framework import serializers
5 | from .models import Todo
6 |
7 |
8 | class TodoSerializer(serializers.ModelSerializer):
9 | class Meta:
10 | model = Todo
11 | fields = (
12 | 'id',
13 | 'title',
14 | 'description',
15 | 'completed',
16 | )
17 |
--------------------------------------------------------------------------------
/backend/todo/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/backend/todo/views.py:
--------------------------------------------------------------------------------
1 | from django.shortcuts import render
2 | from rest_framework import viewsets
3 | from .serializers import TodoSerializer
4 | from .models import Todo
5 |
6 |
7 | class TodoView(viewsets.ModelViewSet):
8 | serializer_class = TodoSerializer
9 | queryset = Todo.objects.all()
10 |
--------------------------------------------------------------------------------
/frontend/README.md:
--------------------------------------------------------------------------------
1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2 |
3 | ## Available Scripts
4 |
5 | In the project directory, you can run:
6 |
7 | ### `npm start`
8 |
9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11 |
12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console.
14 |
15 | ### `npm test`
16 |
17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19 |
20 | ### `npm run build`
21 |
22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance.
24 |
25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed!
27 |
28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29 |
30 | ### `npm run eject`
31 |
32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33 |
34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35 |
36 | Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37 |
38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39 |
40 | ## Learn More
41 |
42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43 |
44 | To learn React, check out the [React documentation](https://reactjs.org/).
45 |
--------------------------------------------------------------------------------
/frontend/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "frontend",
3 | "version": "0.1.0",
4 | "private": true,
5 | "proxy": "http://localhost:8000",
6 | "dependencies": {
7 | "axios": "^0.18.0",
8 | "bootstrap": "^4.1.3",
9 | "react": "^16.6.3",
10 | "react-dom": "^16.6.3",
11 | "react-scripts": "2.1.1",
12 | "reactstrap": "^6.5.0"
13 | },
14 | "scripts": {
15 | "start": "react-scripts start",
16 | "build": "react-scripts build",
17 | "test": "react-scripts test",
18 | "eject": "react-scripts eject"
19 | },
20 | "eslintConfig": {
21 | "extends": "react-app"
22 | },
23 | "browserslist": [
24 | ">0.2%",
25 | "not dead",
26 | "not ie <= 11",
27 | "not op_mini all"
28 | ]
29 | }
30 |
--------------------------------------------------------------------------------
/frontend/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dori-dev/django-todo-react/2116629f4f4ba060b7057a6cb800e1eae058e0f9/frontend/public/favicon.ico
--------------------------------------------------------------------------------
/frontend/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |