A Login system built with Vue JS and Django-Ninja

login-vuejs-django-ninja

Sistema de Login entre VueJS e Django-Ninja

Frontend

Instalação

npm install -g @vue/cli

Use node com nvm.

nvm use 18.3.0

Criando o projeto

npm create vite@latest frontend -- --template vue
cd frontend
yarn

# vue create frontend

yarn add vue-router@4 --save
yarn add axios
vue add pinia vee-validate

yarn dev  # ou
# npm run serve

https://vueschool.io/lessons/installing-and-setting-up-vue-router-with-vite-vite-only

# dentro da pasta frontend
mkdir src/plugins
touch src/plugins/vee-validate.js
touch src/plugins/axios.js

Ref: alpinejs-tailwindcss-example

Instalando TailwindCSS

Leia mais

Dados com json-server (Opcional)

npm i -g json-server

Crie db.json

mkdir api
touch api/db.json
{
  "todos": [
    {
      "id": 1,
      "task": "One"
    },
    {
      "id": 2,
      "task": "Two"
    },
    {
      "id": 3,
      "task": "Three"
    }
  ]
}

Rode o json-server

json-server --watch api/db.json

Backend

Bibliotecas

Criando o projeto

python -m venv .venv

source ./venv/bin/activate  # ou
# .venv\Scripts\activate  # Windows

pip install django-ninja-auth python-decouple django-extensions isort autopep8

django-admin startproject backend .
cd backend/

Autenticação

mugartec/django-ninja-auth

TODO: django-ninja-jwt

Rotas

Edite backend/urls.py

# urls.py
from django.contrib import admin
from django.http import JsonResponse
from django.urls import path

from .api import api


def todo(request):
    data = [
        {
            "id": 1,
            "task": "The quick brown fox"
        },
        {
            "id": 2,
            "task": "over the lazy dog"
        }
    ]
    return JsonResponse(data, safe=False)


def about(request):
    return JsonResponse({'status': 'OK'})


urlpatterns = [
    path('todo/', todo),
    path('about/', about),
    path('admin/', admin.site.urls),
    path('api/v1/', api.urls),
]

Crie e edite backend/api.py

# api.py
from ninja import NinjaAPI
from ninja_auth.api import router as auth_router

api = NinjaAPI(csrf=True)

api.add_router('/auth/', auth_router)

Rode as migrações e crie um super usuário.

python manage.py migrate
python manage.py createsuperuser

Rode a aplicação.

python manage.py runserver

Acesse a doc em /api/v1/docs/

GitHub

View Github

Related Posts

Recent Posts

ഇടുക്കിയിലെ മലയോര മേഖലകളിൽ രാത്രിയാത്ര നിരോധിച്ചു. രാത്രി ഏഴു മുതൽ രാവിലെ ആറു വരെയാണ് നിരോധനം

ഏന്തയാർ ഈസ്റ്റിൽ പ്രളയത്തിൽ തകർന്ന പാലത്തിന് പകരം പുതിയ പാലം നിർമ്മിക്കുവാൻ താത്ക്കാലിക പാലം പൊളിച്ച് നീക്കി

Explore the Investment Opportunities: A Comprehensive Guide to Different Types of Mutual Funds

Title: Understanding Mutual Funds: A Beginner's Guide to Investing

തീവ്രമഴ മുന്നറിയിപ്പിന്റെ പശ്ചാതലത്തിൽ സംസ്ഥാനം ജാഗ്രതയിൽ

250,000 അപേക്ഷകൾ വർദ്ധിച്ചതിനാൽ ട്രാൻസ്‌പോർട്ട് കമ്മീഷണർ പരിശോധന പുനരാരംഭിക്കും

ഏലക്കയിൽ കീടനാശിനി സാന്നിധ്യം; ആറര ലക്ഷത്തിലധികം ടിൻ അരവണ നശിപ്പിക്കാൻ ടെൻഡർ ക്ഷണിച്ച് ദേവസ്വം ബോർഡ്‌

ഭീമൻ പാറക്കഷണങ്ങൾ അടർന്ന് ദേശീയ പാതയിലേക്ക് വീഴുന്നത് പതിവാകുന്നു. കുട്ടിക്കാനത്തിനും മുണ്ടക്കയത്തിനുമിടയിൽ നിലനിൽക്കുന്നത് വൻ അപകട ഭീഷണി

ചക്രവാതച്ചുഴി:അതിശക്തമായ മഴ വരുന്നു

പ്ലസ് വൺ പ്രവേശനം. അക്ഷയയിൽ തിക്കി തിരക്കേണ്ട, നെറ്റിവിറ്റി/ജാതി തെളിയിക്കാൻ പത്താംതരം സർട്ടിഫിക്കറ്റ് മതി