Todo app
120 |-
130 | {this.renderItems()}
131 |
├── .gitignore
├── .vscode
└── settings.json
├── Pipfile
├── Pipfile.lock
├── README.md
├── backend
├── backend
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── db.sqlite3
├── manage.py
└── todo
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── migrations
│ ├── 0001_initial.py
│ └── __init__.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 | node_modules/
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "python.pythonPath": "/home/jordan/.local/share/virtualenvs/django-todo-react-rwJ1BMxH/bin/python"
3 | }
--------------------------------------------------------------------------------
/Pipfile:
--------------------------------------------------------------------------------
1 | [[source]]
2 | url = "https://pypi.org/simple"
3 | verify_ssl = true
4 | name = "pypi"
5 |
6 | [packages]
7 | django = "*"
8 |
9 | [dev-packages]
10 |
11 | [requires]
12 | python_version = "3.6"
13 |
--------------------------------------------------------------------------------
/Pipfile.lock:
--------------------------------------------------------------------------------
1 | {
2 | "_meta": {
3 | "hash": {
4 | "sha256": "68309cd71a258c30a39567fce09a09ad5c4ff0bdc85b6fba22b47598c985c883"
5 | },
6 | "pipfile-spec": 6,
7 | "requires": {
8 | "python_version": "3.6"
9 | },
10 | "sources": [
11 | {
12 | "name": "pypi",
13 | "url": "https://pypi.org/simple",
14 | "verify_ssl": true
15 | }
16 | ]
17 | },
18 | "default": {
19 | "django": {
20 | "hashes": [
21 | "sha256:1ffab268ada3d5684c05ba7ce776eaeedef360712358d6a6b340ae9f16486916",
22 | "sha256:dd46d87af4c1bf54f4c926c3cfa41dc2b5c15782f15e4329752ce65f5dad1c37"
23 | ],
24 | "index": "pypi",
25 | "version": "==2.1.3"
26 | },
27 | "pytz": {
28 | "hashes": [
29 | "sha256:31cb35c89bd7d333cd32c5f278fca91b523b0834369e757f4c5641ea252236ca",
30 | "sha256:8e0f8568c118d3077b46be7d654cc8167fa916092e28320cde048e54bfc9f1e6"
31 | ],
32 | "version": "==2018.7"
33 | }
34 | },
35 | "develop": {}
36 | }
37 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Introduction
2 |
3 | This is a simple Todo application built off Django (including the Django REST Framework for API CRUD operations) and React.
4 |
5 | ## Requirements
6 | * Python3
7 | * Pipenv
8 |
9 | ## Getting started
10 | 1. Clone the project to your machine ```[git clone https://github.com/Jordanirabor/django-todo-react]```
11 | 2. Navigate into the diretory ```[cd django-todo-react]```
12 | 3. Source the virtual environment ```[pipenv shell]```
13 | 4. Install the dependencies ```[pipenv install]```
14 | 5. Navigate into the frontend directory ```[cd frontend]```
15 | 5. Install the dependencies ```[npm install]```
16 |
17 | ## Run the application
18 | You will need two terminals pointed to the frontend and backend directories to start the servers for this application.
19 |
20 | 1. Run this command to start the backend server in the ```[backend]``` directory: ```[python manage.py runserver]``` (You have to run this command while you are sourced into the virtual environment)
21 | 2. Run this command to start the frontend development server in the ```[frontend]``` directory: ```[npm install]``` (This will start the frontend on the adddress [localhost:3000](http://localhost:3000))
22 |
23 | ## Built With
24 |
25 | * [React](https://reactjs.org) - A progressive JavaScript framework.
26 | * [Python](https://www.python.org/) - A programming language that lets you work quickly and integrate systems more effectively.
27 | * [Django](http://djangoproject.org/) - A high-level Python Web framework that encourages rapid development and clean, pragmatic design.
--------------------------------------------------------------------------------
/backend/backend/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Jordanirabor/django-todo-react/f18e4ee5e0562c41d39e096eb83f3835e11bccd5/backend/backend/__init__.py
--------------------------------------------------------------------------------
/backend/backend/settings.py:
--------------------------------------------------------------------------------
1 | """
2 | Django settings for backend project.
3 |
4 | Generated by 'django-admin startproject' using Django 2.1.3.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/2.1/topics/settings/
8 |
9 | For the full list of settings and their values, see
10 | https://docs.djangoproject.com/en/2.1/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 |
18 |
19 | # Quick-start development settings - unsuitable for production
20 | # See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
21 |
22 | # SECURITY WARNING: keep the secret key used in production secret!
23 | SECRET_KEY = 'l4y@!^rox=b*!x-qd9xa*nt%r$$zcp!p_d&1gh@b99s-#iqsj&'
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 | INSTALLED_APPS = [
33 | 'django.contrib.admin',
34 | 'django.contrib.auth',
35 | 'django.contrib.contenttypes',
36 | 'django.contrib.sessions',
37 | 'django.contrib.messages',
38 | 'django.contrib.staticfiles',
39 | 'corsheaders', # add this
40 | 'rest_framework', # add this
41 | 'todo',
42 | ]
43 |
44 |
45 | MIDDLEWARE = [
46 | 'corsheaders.middleware.CorsMiddleware', # add this
47 | 'django.middleware.security.SecurityMiddleware',
48 | 'django.contrib.sessions.middleware.SessionMiddleware',
49 | 'django.middleware.common.CommonMiddleware',
50 | 'django.middleware.csrf.CsrfViewMiddleware',
51 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
52 | 'django.contrib.messages.middleware.MessageMiddleware',
53 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
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/2.1/ref/settings/#databases
79 |
80 | DATABASES = {
81 | 'default': {
82 | 'ENGINE': 'django.db.backends.sqlite3',
83 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
84 | }
85 | }
86 |
87 |
88 | # Password validation
89 | # https://docs.djangoproject.com/en/2.1/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/2.1/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/2.1/howto/static-files/
123 |
124 | STATIC_URL = '/static/'
125 |
126 |
127 | # we whitelist localhost:3000 because that's where frontend will be served
128 | CORS_ORIGIN_WHITELIST = (
129 | 'localhost:3000/'
130 | )
131 |
--------------------------------------------------------------------------------
/backend/backend/urls.py:
--------------------------------------------------------------------------------
1 |
2 | # backend/urls.py
3 |
4 | from django.contrib import admin
5 | from django.urls import path, include # add this
6 | from rest_framework import routers # add this
7 | from todo import views # add this
8 |
9 | router = routers.DefaultRouter() # add this
10 | router.register(r'todos', views.TodoView, 'todo') # add this
11 |
12 | urlpatterns = [
13 | path('admin/', admin.site.urls),
14 | path('api/', include(router.urls)) # add this
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/2.1/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/db.sqlite3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Jordanirabor/django-todo-react/f18e4ee5e0562c41d39e096eb83f3835e11bccd5/backend/db.sqlite3
--------------------------------------------------------------------------------
/backend/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import os
3 | import sys
4 |
5 | if __name__ == '__main__':
6 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')
7 | try:
8 | from django.core.management import execute_from_command_line
9 | except ImportError as exc:
10 | raise ImportError(
11 | "Couldn't import Django. Are you sure it's installed and "
12 | "available on your PYTHONPATH environment variable? Did you "
13 | "forget to activate a virtual environment?"
14 | ) from exc
15 | execute_from_command_line(sys.argv)
16 |
--------------------------------------------------------------------------------
/backend/todo/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Jordanirabor/django-todo-react/f18e4ee5e0562c41d39e096eb83f3835e11bccd5/backend/todo/__init__.py
--------------------------------------------------------------------------------
/backend/todo/admin.py:
--------------------------------------------------------------------------------
1 |
2 | # todo/admin.py
3 |
4 | from django.contrib import admin
5 | from .models import Todo # add this
6 |
7 | class TodoAdmin(admin.ModelAdmin): # add this
8 | list_display = ('title', 'description', 'completed') # add this
9 |
10 | # Register your models here.
11 | admin.site.register(Todo, TodoAdmin) # add this
--------------------------------------------------------------------------------
/backend/todo/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class TodoConfig(AppConfig):
5 | name = 'todo'
6 |
--------------------------------------------------------------------------------
/backend/todo/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.1.3 on 2018-11-17 08:51
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='Todo',
16 | fields=[
17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18 | ('title', models.CharField(max_length=120)),
19 | ('description', models.TextField()),
20 | ('completed', models.BooleanField(default=False)),
21 | ],
22 | ),
23 | ]
24 |
--------------------------------------------------------------------------------
/backend/todo/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Jordanirabor/django-todo-react/f18e4ee5e0562c41d39e096eb83f3835e11bccd5/backend/todo/migrations/__init__.py
--------------------------------------------------------------------------------
/backend/todo/models.py:
--------------------------------------------------------------------------------
1 |
2 | # todo/models.py
3 |
4 | from django.db import models
5 | # Create your models here.
6 |
7 | # add this
8 | class Todo(models.Model):
9 | title = models.CharField(max_length=120)
10 | description = models.TextField()
11 | completed = models.BooleanField(default=False)
12 |
13 | def __str__(self):
14 | return self.title
--------------------------------------------------------------------------------
/backend/todo/serializers.py:
--------------------------------------------------------------------------------
1 |
2 | # todo/serializers.py
3 |
4 | from rest_framework import serializers
5 | from .models import Todo
6 |
7 | class TodoSerializer(serializers.ModelSerializer):
8 | class Meta:
9 | model = Todo
10 | fields = ('id', 'title', 'description', 'completed')
--------------------------------------------------------------------------------
/backend/todo/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/backend/todo/views.py:
--------------------------------------------------------------------------------
1 |
2 | # todo/views.py
3 |
4 | from django.shortcuts import render
5 | from rest_framework import viewsets # add this
6 | from .serializers import TodoSerializer # add this
7 | from .models import Todo # add this
8 |
9 | class TodoView(viewsets.ModelViewSet): # add this
10 | serializer_class = TodoSerializer # add this
11 | queryset = Todo.objects.all() # add this
--------------------------------------------------------------------------------
/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/Jordanirabor/django-todo-react/f18e4ee5e0562c41d39e096eb83f3835e11bccd5/frontend/public/favicon.ico
--------------------------------------------------------------------------------
/frontend/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |