Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Installation

Django

pip3 install django
pip3 install djangorestframework
pip3 install django-cors-headers

python3 -m django startproject main
cd main
python3 manage.py runserver

/main/settings.py

INSTALLED_APPS = [
    ...
+   'rest_framework',
+   'corsheaders',
]

MIDDLEWARE = [
+    'corsheaders.middleware.CorsMiddleware', # At the top of the list
    ...
]

+ CORS_ORIGIN_WHITELIST = [
+     'http://localhost:8000',
+     'http://127.0.0.1:8000',
+     'http://localhost:3000'
+ ]

React

Moving the React project to the Django project. Rename the folder to frontend.

cd frontend
yarn
yarn build

/main/settings.py

...
TEMPLATES = [
    {
        ...
-       'DIRS': [],
+       'DIRS': [
+           BASE_DIR / 'frontend/build'
+       ],
        ...
    },
]
...

+ STATICFILES_DIRS = [
+     BASE_DIR / 'frontend/build/static'
+ ]

/main/urls.py

from django.contrib import admin
from django.urls import path
+ from django.views.generic import TemplateView

urlpatterns = [
    path('admin/', admin.site.urls),
+   path("", TemplateView.as_view(template_name="index.html"))
]

Applications

Part of the project.

Models ─┬─ Serializers ─ Views ─ Urls ─ Main/Urls
        └─ Admin

Add

python3 manage.py startapp <name>

/main/settings.py

INSTALLED_APPS = [
    ...
    'django.contrib.messages',
+   '<name>',
]

/main/urls.py

- from django.urls import path
+ from django.urls import path, include

urlpatterns = [
    ...
+   path('<name>/', include('<name>.urls')),
]
touch <name>/urls.py
touch <name>/serializers.py

Models

Working with the database.

/<name>/models.py

python3 manage.py makemigrations
python3 manage.py migrate

Super user:

python3 manage.py createsuperuser

Authentication

pip3 install PyJWT

/api/serializers.py... /api/views.py... /main/views.py...

Commit: Django API Authentication using JWT Tokens

Stack

  • Python3
  • Django
  • Django REST framework
  • TypeScript
  • React
  • Redux
  • Saga
  • Jest
  • Prototypes
  • Material-UI
  • React Router DOM

Sources of

About

DJANGO-REACT BUILD: Python3 // Django // Django REST framework // TypeScript // React // Redux // Saga // Jest // Prototypes // Material-UI // React Router DOM

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages