├── books ├── __init__.py ├── migrations │ ├── __init__.py │ └── 0001_initial.py ├── admin.py ├── apps.py ├── templates │ ├── components │ │ └── form.html │ ├── base.html │ └── pages │ │ └── home.html ├── tests.py ├── form.py ├── serializer.py ├── models.py └── views.py ├── DjangoReact ├── __init__.py ├── __pycache__ │ ├── urls.cpython-36.pyc │ ├── wsgi.cpython-36.pyc │ ├── __init__.cpython-36.pyc │ └── settings.cpython-36.pyc ├── asgi.py ├── wsgi.py ├── urls.py └── settings.py ├── db.sqlite3 ├── frontend ├── build │ ├── favicon.ico │ ├── logo192.png │ ├── logo512.png │ ├── robots.txt │ ├── static │ │ ├── css │ │ │ ├── main.5ecd60fb.chunk.css │ │ │ └── main.5ecd60fb.chunk.css.map │ │ └── js │ │ │ ├── 2.112182d7.chunk.js.LICENSE.txt │ │ │ ├── runtime-main.c8a21426.js │ │ │ ├── main.333fd2e6.chunk.js │ │ │ ├── runtime-main.c8a21426.js.map │ │ │ └── main.333fd2e6.chunk.js.map │ ├── manifest.json │ ├── precache-manifest.b43d8b462286b27c257b49e24040287a.js │ ├── asset-manifest.json │ ├── service-worker.js │ └── index.html ├── public │ ├── robots.txt │ ├── favicon.ico │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── index.html ├── src │ ├── setupTests.js │ ├── App.test.js │ ├── index.css │ ├── index.js │ ├── App.css │ ├── logo.svg │ ├── App.js │ └── serviceWorker.js ├── package.json └── README.md ├── todo.md ├── Pipfile ├── .gitignore ├── README.md ├── manage.py └── Pipfile.lock /books/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /DjangoReact/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /books/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baris5d/DjangoReact/HEAD/db.sqlite3 -------------------------------------------------------------------------------- /books/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /frontend/build/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baris5d/DjangoReact/HEAD/frontend/build/favicon.ico -------------------------------------------------------------------------------- /frontend/build/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baris5d/DjangoReact/HEAD/frontend/build/logo192.png -------------------------------------------------------------------------------- /frontend/build/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baris5d/DjangoReact/HEAD/frontend/build/logo512.png -------------------------------------------------------------------------------- /frontend/build/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /frontend/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /frontend/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baris5d/DjangoReact/HEAD/frontend/public/favicon.ico -------------------------------------------------------------------------------- /frontend/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baris5d/DjangoReact/HEAD/frontend/public/logo192.png -------------------------------------------------------------------------------- /frontend/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baris5d/DjangoReact/HEAD/frontend/public/logo512.png -------------------------------------------------------------------------------- /books/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class BooksConfig(AppConfig): 5 | name = 'books' 6 | -------------------------------------------------------------------------------- /DjangoReact/__pycache__/urls.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baris5d/DjangoReact/HEAD/DjangoReact/__pycache__/urls.cpython-36.pyc -------------------------------------------------------------------------------- /DjangoReact/__pycache__/wsgi.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baris5d/DjangoReact/HEAD/DjangoReact/__pycache__/wsgi.cpython-36.pyc -------------------------------------------------------------------------------- /DjangoReact/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baris5d/DjangoReact/HEAD/DjangoReact/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /DjangoReact/__pycache__/settings.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baris5d/DjangoReact/HEAD/DjangoReact/__pycache__/settings.cpython-36.pyc -------------------------------------------------------------------------------- /books/templates/components/form.html: -------------------------------------------------------------------------------- 1 |
{% csrf_token %} 2 | 3 | {{ form.as_p}} 4 | 5 | 6 |
-------------------------------------------------------------------------------- /todo.md: -------------------------------------------------------------------------------- 1 | Books 2 | -> Creating 3 | -> Name 4 | -> Author 5 | -> Descriptiion 6 | -> Image 7 | -> Search 8 | -> Delete 9 | -> Update 10 | Feed 11 | -> List of all books 12 | -------------------------------------------------------------------------------- /Pipfile: -------------------------------------------------------------------------------- 1 | [[source]] 2 | name = "pypi" 3 | url = "https://pypi.org/simple" 4 | verify_ssl = true 5 | 6 | [dev-packages] 7 | 8 | [packages] 9 | django = "==3.0.8" 10 | djangorestframework = "*" 11 | django-cors-headers = "*" 12 | 13 | [requires] 14 | python_version = "3.6" 15 | -------------------------------------------------------------------------------- /frontend/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /books/templates/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | DjangoReact 7 | 8 | 9 | {% block content %} 10 | {% endblock content %} 11 | 12 | -------------------------------------------------------------------------------- /frontend/src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | const { getByText } = render(); 7 | const linkElement = getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /frontend/build/static/css/main.5ecd60fb.chunk.css: -------------------------------------------------------------------------------- 1 | body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}code{font-family:source-code-pro,Menlo,Monaco,Consolas,"Courier New",monospace} 2 | /*# sourceMappingURL=main.5ecd60fb.chunk.css.map */ -------------------------------------------------------------------------------- /books/tests.py: -------------------------------------------------------------------------------- 1 | from django.contrib.auth import get_user_model 2 | from django.test import TestCase 3 | 4 | from .models import Books 5 | # Create your tests here. 6 | 7 | class BookTestCase(TestCase): 8 | 9 | def test_book_created(self): 10 | book_obj = Books.objects.create(name='Anonymous', author='John Doe', description='lorem ipsum sit door amet.') 11 | self.assertEqual(book_obj.id, 1) -------------------------------------------------------------------------------- /frontend/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /books/form.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | 3 | from .models import Books 4 | 5 | class BooksForm(forms.ModelForm): 6 | class Meta: 7 | model = Books 8 | fields = ['name','author','description'] 9 | def clean_description(self): 10 | description = self.cleaned_data.get('description') 11 | if len(description) > 300: 12 | raise forms.ValidationError("This is too long") 13 | return description -------------------------------------------------------------------------------- /books/serializer.py: -------------------------------------------------------------------------------- 1 | from django.conf import settings 2 | 3 | from rest_framework import serializers 4 | 5 | from .models import Books 6 | 7 | 8 | class BooksSerializer(serializers.ModelSerializer): 9 | class Meta: 10 | model = Books 11 | fields = ['name','author','description'] 12 | 13 | def validate_description(self, value): 14 | if len(value) > 300: 15 | raise serializers.ValidationError("This is too long") 16 | return value -------------------------------------------------------------------------------- /DjangoReact/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for DjangoReact 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', 'DjangoReact.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /DjangoReact/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for DjangoReact 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', 'DjangoReact.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 3 | 4 | # dependencies 5 | /node_modules 6 | /.pnp 7 | .pnp.js 8 | 9 | # testing 10 | /coverage 11 | 12 | # production 13 | /build 14 | 15 | # misc 16 | .DS_Store 17 | .env.local 18 | .env.development.local 19 | .env.test.local 20 | .env.production.local 21 | 22 | npm-debug.log* 23 | yarn-debug.log* 24 | yarn-error.log* 25 | 26 | node_modules/ 27 | 28 | 29 | parse.py 30 | 31 | __pycache__/ 32 | *.py[cod] 33 | *$py.class 34 | 35 | -------------------------------------------------------------------------------- /frontend/build/static/css/main.5ecd60fb.chunk.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["index.css"],"names":[],"mappings":"AAAA,KACE,QAAS,CACT,mJAEY,CACZ,kCAAmC,CACnC,iCACF,CAEA,KACE,yEAEF","file":"main.5ecd60fb.chunk.css","sourcesContent":["body {\n margin: 0;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\n 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',\n monospace;\n}\n"]} -------------------------------------------------------------------------------- /frontend/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import Landing from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root') 12 | ); 13 | 14 | // If you want your app to work offline and load faster, you can change 15 | // unregister() to register() below. Note this comes with some pitfalls. 16 | // Learn more about service workers: https://bit.ly/CRA-PWA 17 | serviceWorker.unregister(); 18 | -------------------------------------------------------------------------------- /books/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | class Books(models.Model): 5 | # id = models.AutoField(primary_key=True) 6 | name = models.TextField(blank=False, null=False) 7 | author = models.TextField(blank=False, null=False) 8 | description = models.TextField() 9 | image = models.FileField(upload_to='images/', blank=True, null=True) 10 | 11 | def serialize(self): 12 | return { 13 | "id" : self.id, 14 | "name": self.name, 15 | "author": self.author, 16 | "description" : self.description 17 | } -------------------------------------------------------------------------------- /frontend/build/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /frontend/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # django-and-react 2 | This repository contains the codes of the articles I prepared for the Django and React development process. You can read my articles from the links below. 3 | 4 | 5 | 6 | ## Links 7 | 8 | [Django ve React ile Full-Stack-Django](https://medium.com/@baris5d/django-ve-react-ile-full-stack-django-8dcecf7e4ef) 9 | [Django ve React ile Full-Stack-React](https://medium.com/@baris5d/django-ve-react-ile-full-stack-react-d9b84b58df8e) 10 | 11 | [Full-Stack with Django and React-Django](https://medium.com/@baris5d/full-stack-with-django-and-react-django-4dcd87d57356) 12 | [Full-Stack with Django and React-React](https://medium.com/@baris5d/full-stack-with-django-and-react-react-afae36017852) 13 | -------------------------------------------------------------------------------- /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', 'DjangoReact.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 | -------------------------------------------------------------------------------- /frontend/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /books/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.0.8 on 2020-07-18 12:00 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='Books', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('name', models.TextField()), 19 | ('author', models.TextField()), 20 | ('description', models.TextField()), 21 | ('image', models.FileField(blank=True, null=True, upload_to='images/')), 22 | ], 23 | ), 24 | ] 25 | -------------------------------------------------------------------------------- /frontend/build/precache-manifest.b43d8b462286b27c257b49e24040287a.js: -------------------------------------------------------------------------------- 1 | self.__precacheManifest = (self.__precacheManifest || []).concat([ 2 | { 3 | "revision": "ab143829cbea274bfd37d372e2b43f88", 4 | "url": "/index.html" 5 | }, 6 | { 7 | "revision": "eb5d2f2327d18ad71c16", 8 | "url": "/static/css/main.5ecd60fb.chunk.css" 9 | }, 10 | { 11 | "revision": "3f0e0d60498fa8c9c696", 12 | "url": "/static/js/2.112182d7.chunk.js" 13 | }, 14 | { 15 | "revision": "c64c486544348f10a6d6c716950bc223", 16 | "url": "/static/js/2.112182d7.chunk.js.LICENSE.txt" 17 | }, 18 | { 19 | "revision": "eb5d2f2327d18ad71c16", 20 | "url": "/static/js/main.333fd2e6.chunk.js" 21 | }, 22 | { 23 | "revision": "2747b914e9a60db2276f", 24 | "url": "/static/js/runtime-main.c8a21426.js" 25 | } 26 | ]); -------------------------------------------------------------------------------- /frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "frontend", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^4.2.4", 7 | "@testing-library/react": "^9.5.0", 8 | "@testing-library/user-event": "^7.2.1", 9 | "axios": ">=0.21.1", 10 | "react": "^16.13.1", 11 | "react-dom": "^16.13.1", 12 | "react-router-dom": "^5.2.0", 13 | "react-scripts": "3.4.1" 14 | }, 15 | "scripts": { 16 | "start": "react-scripts start", 17 | "build": "react-scripts build", 18 | "test": "react-scripts test", 19 | "eject": "react-scripts eject" 20 | }, 21 | "eslintConfig": { 22 | "extends": "react-app" 23 | }, 24 | "browserslist": { 25 | "production": [ 26 | ">0.2%", 27 | "not dead", 28 | "not op_mini all" 29 | ], 30 | "development": [ 31 | "last 1 chrome version", 32 | "last 1 firefox version", 33 | "last 1 safari version" 34 | ] 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /frontend/build/asset-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": { 3 | "main.css": "/static/css/main.5ecd60fb.chunk.css", 4 | "main.js": "/static/js/main.333fd2e6.chunk.js", 5 | "main.js.map": "/static/js/main.333fd2e6.chunk.js.map", 6 | "runtime-main.js": "/static/js/runtime-main.c8a21426.js", 7 | "runtime-main.js.map": "/static/js/runtime-main.c8a21426.js.map", 8 | "static/js/2.112182d7.chunk.js": "/static/js/2.112182d7.chunk.js", 9 | "static/js/2.112182d7.chunk.js.map": "/static/js/2.112182d7.chunk.js.map", 10 | "index.html": "/index.html", 11 | "precache-manifest.b43d8b462286b27c257b49e24040287a.js": "/precache-manifest.b43d8b462286b27c257b49e24040287a.js", 12 | "service-worker.js": "/service-worker.js", 13 | "static/css/main.5ecd60fb.chunk.css.map": "/static/css/main.5ecd60fb.chunk.css.map", 14 | "static/js/2.112182d7.chunk.js.LICENSE.txt": "/static/js/2.112182d7.chunk.js.LICENSE.txt" 15 | }, 16 | "entrypoints": [ 17 | "static/js/runtime-main.c8a21426.js", 18 | "static/js/2.112182d7.chunk.js", 19 | "static/css/main.5ecd60fb.chunk.css", 20 | "static/js/main.333fd2e6.chunk.js" 21 | ] 22 | } -------------------------------------------------------------------------------- /DjangoReact/urls.py: -------------------------------------------------------------------------------- 1 | """DjangoReact 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 18 | 19 | from books.views import ( 20 | home_view, 21 | book_detail_view , 22 | books_list, 23 | book_create_view 24 | ) 25 | 26 | urlpatterns = [ 27 | path('admin/', admin.site.urls), 28 | path('', home_view), 29 | path('create-book', book_create_view), 30 | path('books/', books_list), 31 | path('books/', book_detail_view), 32 | ] 33 | -------------------------------------------------------------------------------- /frontend/build/static/js/2.112182d7.chunk.js.LICENSE.txt: -------------------------------------------------------------------------------- 1 | /* 2 | object-assign 3 | (c) Sindre Sorhus 4 | @license MIT 5 | */ 6 | 7 | /** @license React v0.19.1 8 | * scheduler.production.min.js 9 | * 10 | * Copyright (c) Facebook, Inc. and its affiliates. 11 | * 12 | * This source code is licensed under the MIT license found in the 13 | * LICENSE file in the root directory of this source tree. 14 | */ 15 | 16 | /** @license React v16.13.1 17 | * react-dom.production.min.js 18 | * 19 | * Copyright (c) Facebook, Inc. and its affiliates. 20 | * 21 | * This source code is licensed under the MIT license found in the 22 | * LICENSE file in the root directory of this source tree. 23 | */ 24 | 25 | /** @license React v16.13.1 26 | * react-is.production.min.js 27 | * 28 | * Copyright (c) Facebook, Inc. and its affiliates. 29 | * 30 | * This source code is licensed under the MIT license found in the 31 | * LICENSE file in the root directory of this source tree. 32 | */ 33 | 34 | /** @license React v16.13.1 35 | * react.production.min.js 36 | * 37 | * Copyright (c) Facebook, Inc. and its affiliates. 38 | * 39 | * This source code is licensed under the MIT license found in the 40 | * LICENSE file in the root directory of this source tree. 41 | */ 42 | -------------------------------------------------------------------------------- /frontend/build/service-worker.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Welcome to your Workbox-powered service worker! 3 | * 4 | * You'll need to register this file in your web app and you should 5 | * disable HTTP caching for this file too. 6 | * See https://goo.gl/nhQhGp 7 | * 8 | * The rest of the code is auto-generated. Please don't update this file 9 | * directly; instead, make changes to your Workbox build configuration 10 | * and re-run your build process. 11 | * See https://goo.gl/2aRDsh 12 | */ 13 | 14 | importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js"); 15 | 16 | importScripts( 17 | "/precache-manifest.b43d8b462286b27c257b49e24040287a.js" 18 | ); 19 | 20 | self.addEventListener('message', (event) => { 21 | if (event.data && event.data.type === 'SKIP_WAITING') { 22 | self.skipWaiting(); 23 | } 24 | }); 25 | 26 | workbox.core.clientsClaim(); 27 | 28 | /** 29 | * The workboxSW.precacheAndRoute() method efficiently caches and responds to 30 | * requests for URLs in the manifest. 31 | * See https://goo.gl/S9QRab 32 | */ 33 | self.__precacheManifest = [].concat(self.__precacheManifest || []); 34 | workbox.precaching.precacheAndRoute(self.__precacheManifest, {}); 35 | 36 | workbox.routing.registerNavigationRoute(workbox.precaching.getCacheKeyForURL("/index.html"), { 37 | 38 | blacklist: [/^\/_/,/\/[^/?]+\.[^/]+$/], 39 | }); 40 | -------------------------------------------------------------------------------- /frontend/build/static/js/runtime-main.c8a21426.js: -------------------------------------------------------------------------------- 1 | !function(e){function r(r){for(var n,f,l=r[0],i=r[1],a=r[2],c=0,s=[];cDjangoReact 4 |
5 | {% csrf_token %} 6 | 7 | 8 | 9 | 10 | 11 |
12 |
13 | 40 | 41 | {% endblock content %} -------------------------------------------------------------------------------- /frontend/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /frontend/build/index.html: -------------------------------------------------------------------------------- 1 | React App
-------------------------------------------------------------------------------- /books/views.py: -------------------------------------------------------------------------------- 1 | from django.conf import settings 2 | from django.http import HttpResponse, Http404, JsonResponse 3 | from django.shortcuts import render,redirect 4 | from django.utils.http import is_safe_url 5 | 6 | from rest_framework.response import Response 7 | from rest_framework.decorators import api_view 8 | 9 | from .models import Books 10 | from .form import BooksForm 11 | from django.conf import settings 12 | from .serializer import BooksSerializer 13 | 14 | 15 | ALLOWED_HOSTS = settings.ALLOWED_HOSTS 16 | 17 | def home_view(request, *args, **kwargs): 18 | return render(request, 'pages/home.html', context={}, status=200) 19 | 20 | @api_view(['GET']) 21 | def books_list(request, *args, **kwargs): 22 | blist = Books.objects.all() 23 | books = [x.serialize() for x in blist] 24 | data = { 25 | "response" : books 26 | } 27 | return Response(data) 28 | 29 | @api_view(['GET']) 30 | def book_detail_view(request, book_id, *args, **kwargs): 31 | data = { 32 | "id" : book_id 33 | } 34 | status = 200 35 | try: 36 | obj = Books.objects.get(id=book_id) 37 | data['name'] = obj.name 38 | data['author'] = obj.author 39 | data['description'] = obj.description 40 | data['status'] = "ok" 41 | 42 | except: 43 | data['message'] = "Not Found" 44 | data['status'] = "error" 45 | return Response(data,status=status) 46 | 47 | @api_view(['POST']) 48 | def book_create_view(request, *args, **kwargs): 49 | print(request.POST) 50 | serializer = BooksSerializer(data=request.data or None) 51 | if serializer.is_valid(raise_exception = True): 52 | serializer.save() 53 | return Response(serializer.data) 54 | return Response({}, status=400) 55 | 56 | # without serializer 57 | def book_create_view_pure(request, *args, **kwargs): 58 | form = BooksForm(request.POST or None) 59 | next_url = request.POST.get('next') or None 60 | if form.is_valid(): 61 | obj = form.save(commit=False) 62 | obj.save() 63 | if next_url != None and is_safe_url(next_url,ALLOWED_HOSTS): 64 | return redirect(next_url) 65 | form = BooksForm() 66 | return render(request, 'components/form.html', context={'form': form}) -------------------------------------------------------------------------------- /frontend/src/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Pipfile.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_meta": { 3 | "hash": { 4 | "sha256": "b08855a7395386379274920742813e068d8e0111c5d51c43ecb608dbb884b8f0" 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 | "asgiref": { 20 | "hashes": [ 21 | "sha256:7e51911ee147dd685c3c8b805c0ad0cb58d360987b56953878f8c06d2d1c6f1a", 22 | "sha256:9fc6fb5d39b8af147ba40765234fa822b39818b12cc80b35ad9b0cef3a476aed" 23 | ], 24 | "markers": "python_version >= '3.5'", 25 | "version": "==3.2.10" 26 | }, 27 | "django": { 28 | "hashes": [ 29 | "sha256:31a5fbbea5fc71c99e288ec0b2f00302a0a92c44b13ede80b73a6a4d6d205582", 30 | "sha256:5457fc953ec560c5521b41fad9e6734a4668b7ba205832191bbdff40ec61073c" 31 | ], 32 | "index": "pypi", 33 | "version": "==3.0.8" 34 | }, 35 | "django-cors-headers": { 36 | "hashes": [ 37 | "sha256:5240062ef0b16668ce8a5f43324c388d65f5439e1a30e22c38684d5ddaff0d15", 38 | "sha256:f5218f2f0bb1210563ff87687afbf10786e080d8494a248e705507ebd92d7153" 39 | ], 40 | "index": "pypi", 41 | "version": "==3.4.0" 42 | }, 43 | "djangorestframework": { 44 | "hashes": [ 45 | "sha256:05809fc66e1c997fd9a32ea5730d9f4ba28b109b9da71fccfa5ff241201fd0a4", 46 | "sha256:e782087823c47a26826ee5b6fa0c542968219263fb3976ec3c31edab23a4001f" 47 | ], 48 | "index": "pypi", 49 | "version": "==3.11.0" 50 | }, 51 | "pytz": { 52 | "hashes": [ 53 | "sha256:a494d53b6d39c3c6e44c3bec237336e14305e4f29bbf800b599253057fbb79ed", 54 | "sha256:c35965d010ce31b23eeb663ed3cc8c906275d6be1a34393a1d73a41febf4a048" 55 | ], 56 | "version": "==2020.1" 57 | }, 58 | "sqlparse": { 59 | "hashes": [ 60 | "sha256:022fb9c87b524d1f7862b3037e541f68597a730a8843245c349fc93e1643dc4e", 61 | "sha256:e162203737712307dfe78860cc56c8da8a852ab2ee33750e33aeadf38d12c548" 62 | ], 63 | "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", 64 | "version": "==0.3.1" 65 | } 66 | }, 67 | "develop": {} 68 | } 69 | -------------------------------------------------------------------------------- /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 | 46 | ### Code Splitting 47 | 48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting 49 | 50 | ### Analyzing the Bundle Size 51 | 52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size 53 | 54 | ### Making a Progressive Web App 55 | 56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app 57 | 58 | ### Advanced Configuration 59 | 60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration 61 | 62 | ### Deployment 63 | 64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment 65 | 66 | ### `npm run build` fails to minify 67 | 68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify 69 | -------------------------------------------------------------------------------- /DjangoReact/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for DjangoReact project. 3 | 4 | Generated by 'django-admin startproject' using Django 3.0.8. 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 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = '!e_&f@hb3@x(=im=*oeya05@53e$%9a^$@jrwho%63g(k5%p)j' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [ 29 | '127.0.0.1' 30 | ] 31 | CORS_ORIGIN_ALLOW_ALL = True 32 | 33 | # Application definition 34 | 35 | INSTALLED_APPS = [ 36 | 'django.contrib.admin', 37 | 'django.contrib.auth', 38 | 'django.contrib.contenttypes', 39 | 'django.contrib.sessions', 40 | 'django.contrib.messages', 41 | 'django.contrib.staticfiles', 42 | 'rest_framework', 43 | 'books', 44 | 'corsheaders' 45 | ] 46 | 47 | MIDDLEWARE = [ 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 | 'corsheaders.middleware.CorsMiddleware' 56 | ] 57 | 58 | ROOT_URLCONF = 'DjangoReact.urls' 59 | 60 | TEMPLATES = [ 61 | { 62 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 63 | 'DIRS': [os.path.join(BASE_DIR, "templates")], 64 | 'APP_DIRS': True, 65 | 'OPTIONS': { 66 | 'context_processors': [ 67 | 'django.template.context_processors.debug', 68 | 'django.template.context_processors.request', 69 | 'django.contrib.auth.context_processors.auth', 70 | 'django.contrib.messages.context_processors.messages', 71 | ], 72 | }, 73 | }, 74 | ] 75 | 76 | WSGI_APPLICATION = 'DjangoReact.wsgi.application' 77 | 78 | 79 | # Database 80 | # https://docs.djangoproject.com/en/3.0/ref/settings/#databases 81 | 82 | DATABASES = { 83 | 'default': { 84 | 'ENGINE': 'django.db.backends.sqlite3', 85 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 86 | } 87 | } 88 | 89 | 90 | # Password validation 91 | # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators 92 | 93 | AUTH_PASSWORD_VALIDATORS = [ 94 | { 95 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 96 | }, 97 | { 98 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 99 | }, 100 | { 101 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 102 | }, 103 | { 104 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 105 | }, 106 | ] 107 | 108 | 109 | # Internationalization 110 | # https://docs.djangoproject.com/en/3.0/topics/i18n/ 111 | 112 | LANGUAGE_CODE = 'en-us' 113 | 114 | TIME_ZONE = 'UTC' 115 | 116 | USE_I18N = True 117 | 118 | USE_L10N = True 119 | 120 | USE_TZ = True 121 | 122 | 123 | # Static files (CSS, JavaScript, Images) 124 | # https://docs.djangoproject.com/en/3.0/howto/static-files/ 125 | 126 | STATIC_URL = '/frontend/build/' 127 | -------------------------------------------------------------------------------- /frontend/build/static/js/main.333fd2e6.chunk.js: -------------------------------------------------------------------------------- 1 | (this.webpackJsonpfrontend=this.webpackJsonpfrontend||[]).push([[0],{31:function(e,t,n){e.exports=n(60)},36:function(e,t,n){},60:function(e,t,n){"use strict";n.r(t);var a=n(0),r=n.n(a),c=n(29),o=n.n(c),l=(n(36),n(11)),u=n.n(l),i=n(15),s=n(12),m=n(16),p=n(9),f=n(1),h=n(13),E=n.n(h),b=n(8);function d(e){var t=null;if(document.cookie&&""!==document.cookie)for(var n=document.cookie.split(";"),a=0;a 53 |

DjangoReact - Create Book

54 |
55 | 56 | 57 | 58 | 59 |
60 | 61 | ) 62 | } 63 | 64 | 65 | function Book(props){ 66 | const {book} = props 67 | return( 68 |
69 |

{book.name}

70 |

{book.author}

71 |

{book.description}

72 |
73 | ) 74 | } 75 | 76 | function App() { 77 | const[books,setBooks] = useState([]) 78 | const[hasError, setErrors] = useState(false) 79 | 80 | useEffect (() => { 81 | async function fetchBooks() { 82 | const res = await fetch("http://127.0.0.1:8000/books/"); 83 | res 84 | .json() 85 | .then(res => setBooks(res.response)) 86 | .catch(err => setErrors(err)); 87 | } 88 | 89 | fetchBooks(); 90 | },[]) 91 | 92 | return ( 93 |
94 |
95 |

DjangoReact - Books List

96 |
97 |
98 | {books.map((item,index) => { 99 | return ( 100 | 101 | )} 102 | )} 103 | {hasError} 104 |
105 |
106 | ); 107 | } 108 | 109 | function SingularBook(params) { 110 | const{ id } = useParams() 111 | const[book,setBook] = useState([]) 112 | const[error, setError] = useState(false) 113 | 114 | useEffect (() => { 115 | async function fetchBooks() { 116 | const res = await fetch("http://127.0.0.1:8000/books/"+id); 117 | res 118 | .json() 119 | .then(res => setBook(res)) 120 | .catch(err => setError(err)); 121 | } 122 | 123 | fetchBooks(); 124 | },[]) 125 | 126 | return ( 127 |
128 |
129 |
130 | 131 | { error || book.status==="error" ? 132 |

Something went wrong

133 | : 134 |
135 |

{book.name}

136 |

{book.author}

137 |

{book.description}

138 |
139 | } 140 |
141 | ); 142 | } 143 | 144 | export default function Landing(){ 145 | return( 146 | 147 |
148 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 |
171 |
172 | ) 173 | } 174 | 175 | -------------------------------------------------------------------------------- /frontend/src/serviceWorker.js: -------------------------------------------------------------------------------- 1 | // This optional code is used to register a service worker. 2 | // register() is not called by default. 3 | 4 | // This lets the app load faster on subsequent visits in production, and gives 5 | // it offline capabilities. However, it also means that developers (and users) 6 | // will only see deployed updates on subsequent visits to a page, after all the 7 | // existing tabs open on the page have been closed, since previously cached 8 | // resources are updated in the background. 9 | 10 | // To learn more about the benefits of this model and instructions on how to 11 | // opt-in, read https://bit.ly/CRA-PWA 12 | 13 | const isLocalhost = Boolean( 14 | window.location.hostname === 'localhost' || 15 | // [::1] is the IPv6 localhost address. 16 | window.location.hostname === '[::1]' || 17 | // 127.0.0.0/8 are considered localhost for IPv4. 18 | window.location.hostname.match( 19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ 20 | ) 21 | ); 22 | 23 | export function register(config) { 24 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { 25 | // The URL constructor is available in all browsers that support SW. 26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); 27 | if (publicUrl.origin !== window.location.origin) { 28 | // Our service worker won't work if PUBLIC_URL is on a different origin 29 | // from what our page is served on. This might happen if a CDN is used to 30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374 31 | return; 32 | } 33 | 34 | window.addEventListener('load', () => { 35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 36 | 37 | if (isLocalhost) { 38 | // This is running on localhost. Let's check if a service worker still exists or not. 39 | checkValidServiceWorker(swUrl, config); 40 | 41 | // Add some additional logging to localhost, pointing developers to the 42 | // service worker/PWA documentation. 43 | navigator.serviceWorker.ready.then(() => { 44 | console.log( 45 | 'This web app is being served cache-first by a service ' + 46 | 'worker. To learn more, visit https://bit.ly/CRA-PWA' 47 | ); 48 | }); 49 | } else { 50 | // Is not localhost. Just register service worker 51 | registerValidSW(swUrl, config); 52 | } 53 | }); 54 | } 55 | } 56 | 57 | function registerValidSW(swUrl, config) { 58 | navigator.serviceWorker 59 | .register(swUrl) 60 | .then(registration => { 61 | registration.onupdatefound = () => { 62 | const installingWorker = registration.installing; 63 | if (installingWorker == null) { 64 | return; 65 | } 66 | installingWorker.onstatechange = () => { 67 | if (installingWorker.state === 'installed') { 68 | if (navigator.serviceWorker.controller) { 69 | // At this point, the updated precached content has been fetched, 70 | // but the previous service worker will still serve the older 71 | // content until all client tabs are closed. 72 | console.log( 73 | 'New content is available and will be used when all ' + 74 | 'tabs for this page are closed. See https://bit.ly/CRA-PWA.' 75 | ); 76 | 77 | // Execute callback 78 | if (config && config.onUpdate) { 79 | config.onUpdate(registration); 80 | } 81 | } else { 82 | // At this point, everything has been precached. 83 | // It's the perfect time to display a 84 | // "Content is cached for offline use." message. 85 | console.log('Content is cached for offline use.'); 86 | 87 | // Execute callback 88 | if (config && config.onSuccess) { 89 | config.onSuccess(registration); 90 | } 91 | } 92 | } 93 | }; 94 | }; 95 | }) 96 | .catch(error => { 97 | console.error('Error during service worker registration:', error); 98 | }); 99 | } 100 | 101 | function checkValidServiceWorker(swUrl, config) { 102 | // Check if the service worker can be found. If it can't reload the page. 103 | fetch(swUrl, { 104 | headers: { 'Service-Worker': 'script' }, 105 | }) 106 | .then(response => { 107 | // Ensure service worker exists, and that we really are getting a JS file. 108 | const contentType = response.headers.get('content-type'); 109 | if ( 110 | response.status === 404 || 111 | (contentType != null && contentType.indexOf('javascript') === -1) 112 | ) { 113 | // No service worker found. Probably a different app. Reload the page. 114 | navigator.serviceWorker.ready.then(registration => { 115 | registration.unregister().then(() => { 116 | window.location.reload(); 117 | }); 118 | }); 119 | } else { 120 | // Service worker found. Proceed as normal. 121 | registerValidSW(swUrl, config); 122 | } 123 | }) 124 | .catch(() => { 125 | console.log( 126 | 'No internet connection found. App is running in offline mode.' 127 | ); 128 | }); 129 | } 130 | 131 | export function unregister() { 132 | if ('serviceWorker' in navigator) { 133 | navigator.serviceWorker.ready 134 | .then(registration => { 135 | registration.unregister(); 136 | }) 137 | .catch(error => { 138 | console.error(error.message); 139 | }); 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /frontend/build/static/js/runtime-main.c8a21426.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["../webpack/bootstrap"],"names":["webpackJsonpCallback","data","moduleId","chunkId","chunkIds","moreModules","executeModules","i","resolves","length","Object","prototype","hasOwnProperty","call","installedChunks","push","modules","parentJsonpFunction","shift","deferredModules","apply","checkDeferredModules","result","deferredModule","fulfilled","j","depId","splice","__webpack_require__","s","installedModules","1","exports","module","l","m","c","d","name","getter","o","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","p","jsonpArray","this","oldJsonpFunction","slice"],"mappings":"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","file":"static/js/runtime-main.c8a21426.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tfunction webpackJsonpCallback(data) {\n \t\tvar chunkIds = data[0];\n \t\tvar moreModules = data[1];\n \t\tvar executeModules = data[2];\n\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [];\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) {\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\t}\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(data);\n\n \t\twhile(resolves.length) {\n \t\t\tresolves.shift()();\n \t\t}\n\n \t\t// add entry modules from loaded chunk to deferred list\n \t\tdeferredModules.push.apply(deferredModules, executeModules || []);\n\n \t\t// run deferred modules when all chunks ready\n \t\treturn checkDeferredModules();\n \t};\n \tfunction checkDeferredModules() {\n \t\tvar result;\n \t\tfor(var i = 0; i < deferredModules.length; i++) {\n \t\t\tvar deferredModule = deferredModules[i];\n \t\t\tvar fulfilled = true;\n \t\t\tfor(var j = 1; j < deferredModule.length; j++) {\n \t\t\t\tvar depId = deferredModule[j];\n \t\t\t\tif(installedChunks[depId] !== 0) fulfilled = false;\n \t\t\t}\n \t\t\tif(fulfilled) {\n \t\t\t\tdeferredModules.splice(i--, 1);\n \t\t\t\tresult = __webpack_require__(__webpack_require__.s = deferredModule[0]);\n \t\t\t}\n \t\t}\n\n \t\treturn result;\n \t}\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// object to store loaded and loading chunks\n \t// undefined = chunk not loaded, null = chunk preloaded/prefetched\n \t// Promise = chunk loading, 0 = chunk loaded\n \tvar installedChunks = {\n \t\t1: 0\n \t};\n\n \tvar deferredModules = [];\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/\";\n\n \tvar jsonpArray = this[\"webpackJsonpfrontend\"] = this[\"webpackJsonpfrontend\"] || [];\n \tvar oldJsonpFunction = jsonpArray.push.bind(jsonpArray);\n \tjsonpArray.push = webpackJsonpCallback;\n \tjsonpArray = jsonpArray.slice();\n \tfor(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);\n \tvar parentJsonpFunction = oldJsonpFunction;\n\n\n \t// run deferred modules from other chunks\n \tcheckDeferredModules();\n"],"sourceRoot":""} -------------------------------------------------------------------------------- /frontend/build/static/js/main.333fd2e6.chunk.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["App.js","serviceWorker.js","index.js"],"names":["getCookie","name","cookieValue","document","cookie","cookies","split","i","length","trim","substring","decodeURIComponent","SendBook","props","useState","author","description","book","setBook","handleChange","event","target","value","className","onSubmit","e","axios","defaults","xsrfCookieName","xsrfHeaderName","preventDefault","post","headers","then","response","console","log","catch","error","type","onChange","Book","to","id","App","books","setBooks","hasError","setErrors","useEffect","a","fetch","json","res","err","fetchBooks","map","item","index","key","SingularBook","params","useParams","setError","status","Landing","path","Boolean","window","location","hostname","match","ReactDOM","render","StrictMode","getElementById","navigator","serviceWorker","ready","registration","unregister","message"],"mappings":"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","file":"static/js/main.333fd2e6.chunk.js","sourcesContent":["import React, {useEffect, useState} from 'react';\nimport { useParams } from 'react-router-dom'\nimport axios from 'axios'\n\nimport {\n BrowserRouter as Router,\n Switch,\n Route,\n Link\n} from \"react-router-dom\";\n\n\n\n//import './App.css';\nfunction getCookie(name) {\n let cookieValue = null;\n if (document.cookie && document.cookie !== '') {\n const cookies = document.cookie.split(';');\n for (let i = 0; i < cookies.length; i++) {\n const cookie = cookies[i].trim();\n // Does this cookie string begin with the name we want?\n if (cookie.substring(0, name.length + 1) === (name + '=')) {\n cookieValue = decodeURIComponent(cookie.substring(name.length + 1));\n break;\n }\n }\n }\n return cookieValue;\n}\n\nfunction SendBook(props){\n const [book, setBook] = useState(\n { name : \"\", author: \"\", description: \"\"}\n );\n const handleChange = (event) => {\n setBook({...book, [event.target.name]: event.target.value})\n }\n const handleSubmit = (e) => {\n \n axios.defaults.xsrfCookieName ='csrftoken';\n axios.defaults.xsrfHeaderName ='X-CSRFToken';\n e.preventDefault()\n axios.post('http://127.0.0.1:8000/create-book', book, {headers: {\"X-CSRFToken\" : getCookie('csrftoken')}})\n .then(function (response) {\n console.log(response)\n })\n .catch(function (error) {\n console.log(error)\n }) \n }\n return(\n
\n

DjangoReact - Create Book

\n
\n \n \n \n \n
\n
\n )\n}\n\n\nfunction Book(props){\n const {book} = props\n return(\n
\n

{book.name}

\n

{book.author}

\n

{book.description}

\n
\n )\n}\n\nfunction App() {\n const[books,setBooks] = useState([])\n const[hasError, setErrors] = useState(false)\n\n useEffect (() => {\n async function fetchBooks() {\n const res = await fetch(\"http://127.0.0.1:8000/books/\");\n res\n .json()\n .then(res => setBooks(res.response))\n .catch(err => setErrors(err));\n }\n\n fetchBooks();\n },[])\n\n return (\n
\n
\n

DjangoReact - Books List

\n
\n
\n {books.map((item,index) => {\n return (\n \n )}\n )}\n {hasError}\n
\n
\n );\n}\n\nfunction SingularBook(params) {\n const{ id } = useParams()\n const[book,setBook] = useState([])\n const[error, setError] = useState(false)\n\n useEffect (() => {\n async function fetchBooks() {\n const res = await fetch(\"http://127.0.0.1:8000/books/\"+id);\n res\n .json()\n .then(res => setBook(res))\n .catch(err => setError(err));\n }\n\n fetchBooks();\n },[])\n\n return (\n
\n
\n
\n \n { error || book.status===\"error\" ? \n

Something went wrong

\n :\n
\n

{book.name}

\n

{book.author}

\n

{book.description}

\n
\n }\n
\n );\n}\n\nexport default function Landing(){\n return(\n \n
\n \n\n \n \n \n \n \n \n \n \n \n \n \n
\n
\n )\n}\n\n","// This optional code is used to register a service worker.\n// register() is not called by default.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on subsequent visits to a page, after all the\n// existing tabs open on the page have been closed, since previously cached\n// resources are updated in the background.\n\n// To learn more about the benefits of this model and instructions on how to\n// opt-in, read https://bit.ly/CRA-PWA\n\nconst isLocalhost = Boolean(\n window.location.hostname === 'localhost' ||\n // [::1] is the IPv6 localhost address.\n window.location.hostname === '[::1]' ||\n // 127.0.0.0/8 are considered localhost for IPv4.\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\n\nexport function register(config) {\n if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\n // The URL constructor is available in all browsers that support SW.\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\n if (publicUrl.origin !== window.location.origin) {\n // Our service worker won't work if PUBLIC_URL is on a different origin\n // from what our page is served on. This might happen if a CDN is used to\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\n return;\n }\n\n window.addEventListener('load', () => {\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\n\n if (isLocalhost) {\n // This is running on localhost. Let's check if a service worker still exists or not.\n checkValidServiceWorker(swUrl, config);\n\n // Add some additional logging to localhost, pointing developers to the\n // service worker/PWA documentation.\n navigator.serviceWorker.ready.then(() => {\n console.log(\n 'This web app is being served cache-first by a service ' +\n 'worker. To learn more, visit https://bit.ly/CRA-PWA'\n );\n });\n } else {\n // Is not localhost. Just register service worker\n registerValidSW(swUrl, config);\n }\n });\n }\n}\n\nfunction registerValidSW(swUrl, config) {\n navigator.serviceWorker\n .register(swUrl)\n .then(registration => {\n registration.onupdatefound = () => {\n const installingWorker = registration.installing;\n if (installingWorker == null) {\n return;\n }\n installingWorker.onstatechange = () => {\n if (installingWorker.state === 'installed') {\n if (navigator.serviceWorker.controller) {\n // At this point, the updated precached content has been fetched,\n // but the previous service worker will still serve the older\n // content until all client tabs are closed.\n console.log(\n 'New content is available and will be used when all ' +\n 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'\n );\n\n // Execute callback\n if (config && config.onUpdate) {\n config.onUpdate(registration);\n }\n } else {\n // At this point, everything has been precached.\n // It's the perfect time to display a\n // \"Content is cached for offline use.\" message.\n console.log('Content is cached for offline use.');\n\n // Execute callback\n if (config && config.onSuccess) {\n config.onSuccess(registration);\n }\n }\n }\n };\n };\n })\n .catch(error => {\n console.error('Error during service worker registration:', error);\n });\n}\n\nfunction checkValidServiceWorker(swUrl, config) {\n // Check if the service worker can be found. If it can't reload the page.\n fetch(swUrl, {\n headers: { 'Service-Worker': 'script' },\n })\n .then(response => {\n // Ensure service worker exists, and that we really are getting a JS file.\n const contentType = response.headers.get('content-type');\n if (\n response.status === 404 ||\n (contentType != null && contentType.indexOf('javascript') === -1)\n ) {\n // No service worker found. Probably a different app. Reload the page.\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister().then(() => {\n window.location.reload();\n });\n });\n } else {\n // Service worker found. Proceed as normal.\n registerValidSW(swUrl, config);\n }\n })\n .catch(() => {\n console.log(\n 'No internet connection found. App is running in offline mode.'\n );\n });\n}\n\nexport function unregister() {\n if ('serviceWorker' in navigator) {\n navigator.serviceWorker.ready\n .then(registration => {\n registration.unregister();\n })\n .catch(error => {\n console.error(error.message);\n });\n }\n}\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport './index.css';\nimport Landing from './App';\nimport * as serviceWorker from './serviceWorker';\n\nReactDOM.render(\n \n \n ,\n document.getElementById('root')\n);\n\n// If you want your app to work offline and load faster, you can change\n// unregister() to register() below. Note this comes with some pitfalls.\n// Learn more about service workers: https://bit.ly/CRA-PWA\nserviceWorker.unregister();\n"],"sourceRoot":""} --------------------------------------------------------------------------------