国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

? ??? ?? ??? ???? Django, Djoser ? JWT? ??? ??? ??? ?? ??? ???: 1?

Django, Djoser ? JWT? ??? ??? ??? ?? ??? ???: 1?

Dec 27, 2024 pm 12:24 PM

? ????? ??? ? ??? ?? ? ??? ?? ?????. ??? ??? ?? ????? ????? ????? ?? ??? ???? ???? ???? ????? ?? ??? ??? ? ????. ??? ??? ? ??? Django REST Framework(DRF)? ???? ???? ?? ? ??? ??? ???? Djoser???. ? ?????? ??? ?? ? ??? ?? ??? ??? ??? ???? Djoser? ???? ?? ??? ?? ???? ???? ??? ???????.

???? ??

????? ????? ??? ??? ?????.

mkdir userauth

??? IDE?? ? ????? ???? ?? ??? ???? ??????

python venv .venv
source .venv/bin/activate

???? ??? ???? ?????.

pip install django djangorestframework djoser djangorestframework_simplejwt social-auth-app-django drf-yasg

??: social-auth-app-django? ?? ?? ???? Djoser? ?? ???? ??? ? ????. ???? ????? ???? ?? ??? ? ????

??? ??? ????.txt ??? ???? ???? ?????.

pip freeze > requirements.txt

?? ???? ???? ????.txt ??? ??? ??? ?? ???? ????? ???.

Django ???? ?? ? ?? ??

django-admin startapp userauth . 

??? ?? django ????? ?????. ?? ?? ???? ?? ?? ???? ???

python manage.py startapp accounts

?? ???? ?????? ??? ????? ???.

  • .venv(????)

  • ??/(???)

  • userauth/(?? ???? ??)

  • manage.py

  • requirements.txt

???? ??

settings.py? INSTALLED_APPS ??? ?? ???? ?? ?????.

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

     # Third Party Apps
    'rest_framework',
    'djoser',
    'rest_framework_simplejwt',
    'drf_yasg',

    # Local Apps
    'accounts',
]

Django REST Framework ? SimpleJWT? ?? ??? ????? settings.py? ???????.

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework_simplejwt.authentication.JWTAuthentication',
    ),
}

???? ??? ?? ??? ??? ??? ?????
?? ??? presents.py ??? ?????
account/managers.py

from django.contrib.auth.models import BaseUserManager


class CustomUserManager(BaseUserManager):

    def create_user(self, email, username, password=None, **extra_fields) -> None:

        if not username:
            raise ValueError("Username is required")

        if not email:
            raise ValueError("Email is required")


        email = self.normalize_email(email)
        user = self.model(email=email, username=username, **extra_fields)
        user.set_password(password)
        user.save()
        return user


    def create_superuser(self, email, username, password, **extra_fields):
        """
        Create and save a SuperUser with the given email and password.
        """
        extra_fields.setdefault("is_staff", True)
        extra_fields.setdefault("is_superuser", True)
        extra_fields.setdefault("is_active", True)

        if extra_fields.get("is_staff") is not True:
            raise ValueError("Superuser must have is_staff=True.")

        if extra_fields.get("is_superuser") is not True:
            raise ValueError("Superuser must have is_superuser=True.")

        return self.create_user(email, username, password, **extra_fields)

accounts/models.py

from django.db import models
from django.contrib.auth.models import AbstractUser
from accounts.managers import CustomUserManager



class CustomUser(AbstractUser):
    username = None
    email = models.EmailField(unique=True)
    is_verified = models.BooleanField(default=False)


    USERNAME_FIELD = 'email'
    REQUIRED_FIELDS = []

    objects = CustomUserManager()


    def __str__(self):
        return self.email

settings.py ??? ?? ?? ?????

AUTH_USER_MODEL = 'accounts.CustomUser'

??????? ??? ?? ?? ?? ??? ??? ? ????

python manage.py makemigrations
python manage.py migrate
python manage.py runserver

????? ??? ?? ????.

Djoser URL ??

API ??? Swagger? ?? Djoser? ????? URL ??? ???? URL? ?????.

userauth/urls.py

from django.contrib import admin
from django.urls import include, path
from rest_framework import permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi


schema_view = get_schema_view(
    openapi.Info(
        title="User Accounts API",
        default_version="v1",
        description="REST implementation of Django authentication system using Djoser",
        contact=openapi.Contact(email="contact@snippets.local"),
        license=openapi.License(name="BSD License"),
    ),
    public=True,
    permission_classes=(permissions.AllowAny,),
)

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/docs', schema_view.with_ui("swagger", cache_timeout=0), name="swagger-ui"),
    path('api/', include('djoser.urls')), 
    path('api/', include('djoser.urls.jwt'))
]

API ??? ??? ?????? http://127.0.0.1:8000/api/docs/? ?????.

Djoser ?? ??

djoser? ?? ??? ? ?? ?? ??? ???? ?? ? ????. Djoser ??

userauth/settings.py

mkdir userauth

??? ???? ??? ???? ??? ???. ??? URL? ???? ??? ? ??? ???? ???? ???? ?????. ??? uid? ???? ??? ??? ????? ??? ??? ?? ???? ??? ???

??? ?? ??

????? ??? ??? ???? ???. ??? ??? ?? mailtrap? ??? ?????. ???? ??? ??? ???? ???? ???? ??? ? ????.

??? ??? ???

python venv .venv
source .venv/bin/activate

?? ?? ??? ????

pip install django djangorestframework djoser djangorestframework_simplejwt social-auth-app-django drf-yasg

?? ???? ??? ?? ???? ????

?? ????? ?? Postman? ???? ????????.

? ??? ???

Step-by-Step Guide to User Authentication with Django, Djoser, and JWT: Part I

??? ????? ??? ???? ?????

Step-by-Step Guide to User Authentication with Django, Djoser, and JWT: Part I

??? ??? ??? ??

??? ???? ?? ????? ?????
?? ????? ??? ??? ??? ?? ??? ??? ???? ??? ??? ??? ?????

??/???/???/activation_email.py
djoser? ?? ???? ?? ???? ??? ?????

pip freeze > requirements.txt

????? ??? ??? ?? ????? djoser ??? ?? ?? ?????

django-admin startapp userauth . 

?? ??? ???? ??? ????.

Step-by-Step Guide to User Authentication with Django, Djoser, and JWT: Part I

??? ?? ??

? ?? ??? ????? ??? ?? ??? ???????.
account/views.py?? ??? ??? ??? ???? ??? ?????:

accounts/views.py

python manage.py startapp accounts

djoser? ??? ??? ???? ??? ???? ??? ??? is_verified ??? true? ?????

??/urls.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

     # Third Party Apps
    'rest_framework',
    'djoser',
    'rest_framework_simplejwt',
    'drf_yasg',

    # Local Apps
    'accounts',
]

???? ??? URL ??
userauth/urls.py

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework_simplejwt.authentication.JWTAuthentication',
    ),
}

?? ?????? ? ??? ???? ???? ???? ??? ??? URL? ?????.
?? ????? URL? ???? ?? ??? ? ???? ???? ???

Step-by-Step Guide to User Authentication with Django, Djoser, and JWT: Part I

URL?? uid? ??? ???? account/urls.py ??? ??? ??? ??? ??? ??? ????

?????? ? ??? ;

mkdir userauth

UID? MTY???
??? cil456-aaf8331efb885f0b4412f35ce544648c???

????? ???? ??? ?????? ?? ????

Step-by-Step Guide to User Authentication with Django, Djoser, and JWT: Part I

???? Djoser? ??? ??? ?? ?? ????? ????. ?? ??? ??? ? ??? ?? ??? ???? ?? ??? ?? ???? ????. ? ???? ? ?? ????? ???? Google, Facebook, GitHub? ?? ?? ???? ???? ???? ???? ? ??? ?? ?? ??? ?? ?????. ???? ?? ??????!

???? ??? ???? ???? ??? ?????.

? ??? Django, Djoser ? JWT? ??? ??? ??? ?? ??? ???: 1?? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

? ??? ?? ?? ?????(SublimeText3)

???

??? ??

?? ????
1786
16
Cakephp ????
1729
56
??? ????
1581
29
PHP ????
1447
31
???
Python? Unittest ?? Pytest ??? ??? ??? ??? ? ???? ?????? Python? Unittest ?? Pytest ??? ??? ??? ??? ? ???? ?????? Jun 19, 2025 am 01:10 AM

Python? Unittest ? Pytest? ??? ? ???? ??, ?? ? ??? ????? ? ?? ?? ???? ??? ??? ?????. 1. ??? ??? ?? ??? ???? ??? ??? ??? ?????. UnitTest? ??? ??? ???? ???? Test \ _? ???? ???? ?????. Pytest? ? ?????. Test \ _?? ???? ?? ? ??????. 2. ??? ?? ?? ? ?? ? ??? ??? ????. UnitTest? Assertequal, AssertTrue ? ?? ??? ???? ?? Pytest? ??? Assert ?? ???? ?? ?? ??? ???? ?????. 3. ?? ??? ?? ? ?? ????? ????? ????.

Numpy ? Pandas? ?? ??????? ??? ?? ? ??? Python? ??? ??? ? ????? Numpy ? Pandas? ?? ??????? ??? ?? ? ??? Python? ??? ??? ? ????? Jun 19, 2025 am 01:04 AM

pythonisidealfordataanalysisduetonumpyandpandas.1) numpyexcelsatnumericalcomputationsfast, multi-dimensionalArraysandectorizedOferationsLikenp.sqrt ()

?? ????? ???? ???? Python?? ??? ?????? ?? ????? ???? ???? Python?? ??? ?????? Jun 20, 2025 am 12:57 AM

?? ????? (DP)? ??? ??? ? ??? ?? ??? ??? ??? ? ??? ??? ?? ??? ???? ??? ????? ??????. ? ?? ?? ??? ????. 1. ??? (??) : ??? ?? ??? ???? ??? ???? ?? ??? ??????. 2. ??? (?) : ?? ???? ???? ????? ?????. ???? ???, ?? ?? ?? ?? ??/?? ?, ??? ??? ?? ?? ?? ??? ??? ????? ?????. ?????? ????? ?? ???? ?? ??? ? ???, ?? ??? ???? ?? ?? ??? ???? ??? ???? ????? ???? ???????.

__iter__ ? __next__? ???? ????? ??? ?? ???? ??? ??? ? ????? __iter__ ? __next__? ???? ????? ??? ?? ???? ??? ??? ? ????? Jun 19, 2025 am 01:12 AM

??? ?? ???? ????? ????? __iter_ ? __next__ ???? ???????. ① __iter__ ???? ??? ? ?? ??? ???? ??? ?? ?? ??? ?????. ② __next__ ???? ? ??? ?? ????, ?? ??? ??? ????, ? ?? ??? ??? stopiteration ??? ??????. status ??? ???? ??????? ?? ??? ??? ?? ?? ??? ???????. pile ?? ?? ???? ?? ??? ?? ? ??? ?? ? ??? ?????? ?????. simple ??? ??? ?? ?? ??? ?? ???? ???? ?? ??? ? ??? ?? ????? ???? ??? ??? ???????.

Python ????? ??? ???? ??? ??? ?? ?? ??? ?????? Python ????? ??? ???? ??? ??? ?? ?? ??? ?????? Jun 19, 2025 am 01:09 AM

Python? ?? ???? ?? ???, ?? ?? ????, ?? ???? ?? ? AI/ML ??? ???? ??? ?????. ??, Cpython? ???? ????? ?? ??, ?? ?? ??? ? ?? ? ?? ??? ?? ??? ??????. ??, ??? ????? ?? ?? ? ?? ??? ????? ?? ?? ? ? ??? ?? ?????. ??, Pyscript ? Nuitka? ?? ?? ???? ??? ??? ?? ??? ?????. ?????, AI ? ??? ?? ??? ?? ???? ??? ?? ???????? ???? ?? ? ??? ?????. ??? ??? Python? ??? ??? ????? ???? ?? ??? ???? ??? ?????.

??? ???? ????? ???? ?????? ??? ?????? ??? ???? ????? ???? ?????? ??? ?????? Jun 20, 2025 am 12:56 AM

Python? ?? ??? ???? ?????? ????, ????? ? ?? ??????? ???? ? ??? ??? ???? ?? ??? ?????. ?? TCP ??? ????? Socket.Socket ()? ???? ??? ??? ?? ? ??? ????? .listen ()? ???? ??? ?? .accept ()? ?? ????? ??? ???????. TCP ?????? ????? ?? ??? ??? ??? ????? .connect ()? ?? ? ?? .sendall ()? ???? ???? ??? .recv ()? ?? ??? ??????. ?? ?????? ????? 1. ??? : ??? ??? ? ???? ??? ? ????. 2. ??? I/O : ?? ??, Asyncio ?????? ? ??? ??? ?? ? ? ????. ???? ? ?

Python?? ??? ??? ???????? Python?? ??? ??? ???????? Jun 20, 2025 am 12:51 AM

Python List ????? ?? ?? ??? [Start : End : Step] ??? ????? ??? ???? ????. 1. ?? ????? ?? ??? ?? [start : end : step]???. ??? ?? ??? (??), ?? ? ??? (???? ??)?? ??? ?? ?????. 2. ????? ???? 0?? ????? ???? ????? ??? ??? ???? ????? ??? 1? ??????. 3. my_list [: n]? ???? ? ?? n ??? ?? my_list [-n :]? ???? ??? n ??? ????. 4. My_List [:: 2]? ?? ??? ?? ?? ??? ???? ??? ??? ?? ?? ?? ??? ???? ? ????. 5. ???? ???? ? ???? ???? ????

??? ???? ??? ??? ???? ??? Jul 05, 2025 am 02:58 AM

???? Python ?? ?? ?????? ?? ????, "??? ?????, ?? ??"? ???? ??? ??? ??? ?? ??? ?????. 1. ???? ?? ? ??? ?? ?????. ?? ???? ?? ??? ???? ??? ? ? ????. ?? ??, Spoke () ?? ???? ??? ??? ?? ??? ?? ????? ?? ??? ??? ????. 2. ???? ?? ???? ??? ??? ?????? Draw () ???? ???? ????? ?? ???? ?? ??? ???? ??? ???? ?? ?? ?? ??? ????? ?? ?? ????? ?? ?????. 3. Python ?? ???? ???????. ?? ???? ??? ???? ?? ???? ??? ????? ??? ?? ???? ??? ???? ????. ??? ??? ??? ???? ? ??? "?? ??"??????. 4. ???? ? ???? ?? ??? ?????

See all articles