liceal 4 gadi atpakaļ
revīzija
8b184c3fb5
41 mainītis faili ar 586 papildinājumiem un 0 dzēšanām
  1. 8 0
      .idea/.gitignore
  2. 28 0
      .idea/Django_test.iml
  3. 11 0
      .idea/dataSources.xml
  4. 4 0
      .idea/encodings.xml
  5. 6 0
      .idea/inspectionProfiles/profiles_settings.xml
  6. 7 0
      .idea/misc.xml
  7. 8 0
      .idea/modules.xml
  8. 6 0
      .idea/vcs.xml
  9. 0 0
      Django_test/__init__.py
  10. BIN
      Django_test/__pycache__/__init__.cpython-37.pyc
  11. BIN
      Django_test/__pycache__/settings.cpython-37.pyc
  12. BIN
      Django_test/__pycache__/urls.cpython-37.pyc
  13. BIN
      Django_test/__pycache__/wsgi.cpython-37.pyc
  14. 16 0
      Django_test/asgi.py
  15. 144 0
      Django_test/settings.py
  16. 26 0
      Django_test/urls.py
  17. 16 0
      Django_test/wsgi.py
  18. 16 0
      Pipfile
  19. 92 0
      Pipfile.lock
  20. 3 0
      README.md
  21. BIN
      __pycache__/manage.cpython-37.pyc
  22. 0 0
      db.sqlite3
  23. 21 0
      manage.py
  24. 0 0
      workreport/__init__.py
  25. BIN
      workreport/__pycache__/__init__.cpython-37.pyc
  26. BIN
      workreport/__pycache__/admin.cpython-37.pyc
  27. BIN
      workreport/__pycache__/models.cpython-37.pyc
  28. BIN
      workreport/__pycache__/serializex.cpython-37.pyc
  29. BIN
      workreport/__pycache__/urls.cpython-37.pyc
  30. BIN
      workreport/__pycache__/views.cpython-37.pyc
  31. 3 0
      workreport/admin.py
  32. 5 0
      workreport/apps.py
  33. 32 0
      workreport/migrations/0001_initial.py
  34. 0 0
      workreport/migrations/__init__.py
  35. BIN
      workreport/migrations/__pycache__/0001_initial.cpython-37.pyc
  36. BIN
      workreport/migrations/__pycache__/__init__.cpython-37.pyc
  37. 18 0
      workreport/models.py
  38. 10 0
      workreport/serializex.py
  39. 3 0
      workreport/tests.py
  40. 19 0
      workreport/urls.py
  41. 84 0
      workreport/views.py

+ 8 - 0
.idea/.gitignore

@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/

+ 28 - 0
.idea/Django_test.iml

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="PYTHON_MODULE" version="4">
+  <component name="FacetManager">
+    <facet type="django" name="Django">
+      <configuration>
+        <option name="rootFolder" value="$MODULE_DIR$" />
+        <option name="settingsModule" value="Django_test/settings.py" />
+        <option name="manageScript" value="$MODULE_DIR$/manage.py" />
+        <option name="environment" value="&lt;map/&gt;" />
+        <option name="doNotUseTestRunner" value="false" />
+        <option name="trackFilePattern" value="migrations" />
+      </configuration>
+    </facet>
+  </component>
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="jdk" jdkName="Python 3.7 (Django_test-jbXSmaBv)" jdkType="Python SDK" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+  <component name="TemplatesService">
+    <option name="TEMPLATE_CONFIGURATION" value="Django" />
+    <option name="TEMPLATE_FOLDERS">
+      <list>
+        <option value="$MODULE_DIR$/../Django_test\templates" />
+      </list>
+    </option>
+  </component>
+</module>

+ 11 - 0
.idea/dataSources.xml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="DataSourceManagerImpl" format="xml" multifile-model="true">
+    <data-source source="LOCAL" name="test_django" uuid="50f427a5-de8e-4ac0-b96d-a4f9256fa79c">
+      <driver-ref>sqlite.xerial</driver-ref>
+      <synchronize>true</synchronize>
+      <jdbc-driver>org.sqlite.JDBC</jdbc-driver>
+      <jdbc-url>jdbc:sqlite:F:\txts\Django_test\test_django</jdbc-url>
+    </data-source>
+  </component>
+</project>

+ 4 - 0
.idea/encodings.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding" addBOMForNewFiles="with NO BOM" />
+</project>

+ 6 - 0
.idea/inspectionProfiles/profiles_settings.xml

@@ -0,0 +1,6 @@
+<component name="InspectionProjectProfileManager">
+  <settings>
+    <option name="USE_PROJECT_PROFILE" value="false" />
+    <version value="1.0" />
+  </settings>
+</component>

+ 7 - 0
.idea/misc.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="JavaScriptSettings">
+    <option name="languageLevel" value="ES6" />
+  </component>
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (Django_test-jbXSmaBv)" project-jdk-type="Python SDK" />
+</project>

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/Django_test.iml" filepath="$PROJECT_DIR$/.idea/Django_test.iml" />
+    </modules>
+  </component>
+</project>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
+  </component>
+</project>

+ 0 - 0
Django_test/__init__.py


BIN
Django_test/__pycache__/__init__.cpython-37.pyc


BIN
Django_test/__pycache__/settings.cpython-37.pyc


BIN
Django_test/__pycache__/urls.cpython-37.pyc


BIN
Django_test/__pycache__/wsgi.cpython-37.pyc


+ 16 - 0
Django_test/asgi.py

@@ -0,0 +1,16 @@
+"""
+ASGI config for Django_test project.
+
+It exposes the ASGI callable as a module-level variable named ``application``.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
+"""
+
+import os
+
+from django.core.asgi import get_asgi_application
+
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Django_test.settings')
+
+application = get_asgi_application()

+ 144 - 0
Django_test/settings.py

@@ -0,0 +1,144 @@
+"""
+Django settings for Django_test project.
+
+Generated by 'django-admin startproject' using Django 3.0.8.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/3.0/topics/settings/
+
+For the full list of settings and their values, see
+https://docs.djangoproject.com/en/3.0/ref/settings/
+"""
+
+import os
+
+# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
+BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+# Quick-start development settings - unsuitable for production
+# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
+
+# SECURITY WARNING: keep the secret key used in production secret!
+SECRET_KEY = '4-0fer)tx1nnb@w$^3zyv13i6i)7*i(j=5b($ayd32t%5rbq+#'
+
+# SECURITY WARNING: don't run with debug turned on in production!
+DEBUG = True
+
+ALLOWED_HOSTS = []
+
+# Application definition
+
+INSTALLED_APPS = [
+    'django.contrib.admin',
+    'django.contrib.auth',
+    'django.contrib.contenttypes',
+    'django.contrib.sessions',
+    'django.contrib.messages',
+    'django.contrib.staticfiles',
+    'rest_framework',
+    'workreport'
+]
+
+MIDDLEWARE = [
+    'django.middleware.security.SecurityMiddleware',
+    'django.contrib.sessions.middleware.SessionMiddleware',
+    'django.middleware.common.CommonMiddleware',
+    'django.middleware.csrf.CsrfViewMiddleware',
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
+    'django.contrib.messages.middleware.MessageMiddleware',
+    'django.middleware.clickjacking.XFrameOptionsMiddleware',
+]
+
+ROOT_URLCONF = 'Django_test.urls'
+
+TEMPLATES = [
+    {
+        'BACKEND': 'django.template.backends.django.DjangoTemplates',
+        'DIRS': [os.path.join(BASE_DIR, 'templates')]
+        ,
+        'APP_DIRS': True,
+        'OPTIONS': {
+            'context_processors': [
+                'django.template.context_processors.debug',
+                'django.template.context_processors.request',
+                'django.contrib.auth.context_processors.auth',
+                'django.contrib.messages.context_processors.messages',
+            ],
+        },
+    },
+]
+
+WSGI_APPLICATION = 'Django_test.wsgi.application'
+
+# Database
+# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
+
+DATABASES = {
+    'default': {
+        'ENGINE': 'django.db.backends.mysql',
+        # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
+        'NAME': 'linxa_django_demo',
+        'USER': 'root',
+        'PASSWORD': 'abc.123',
+        'HOST': 'srv.test.linkerplus.com',
+        'PORT': '3310',
+        'OPTIONS': {
+            'init_command': 'SET sql_mode="STRICT_TRANS_TABLES"',
+            'charset': 'utf8mb4'
+        }
+    }
+}
+
+# Password validation
+# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
+
+AUTH_PASSWORD_VALIDATORS = [
+    {
+        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
+    },
+    {
+        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
+    },
+    {
+        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
+    },
+    {
+        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
+    },
+]
+
+# Internationalization
+# https://docs.djangoproject.com/en/3.0/topics/i18n/
+
+LANGUAGE_CODE = 'en-us'
+
+TIME_ZONE = 'UTC'
+
+USE_I18N = True
+
+USE_L10N = True
+
+USE_TZ = True
+
+# Static files (CSS, JavaScript, Images)
+# https://docs.djangoproject.com/en/3.0/howto/static-files/
+
+STATIC_URL = '/static/'
+
+REST_FRAMEWORK = {
+    'DEFAULT_AUTHENTICATION_CLASSES': (
+        # 'rest_framework.authentication.BasicAuthentication',
+        'rest_framework.authentication.SessionAuthentication',
+        'django.contrib.auth.backends.ModelBackend',
+    ),
+    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
+    'PAGE_SIZE': 3,
+    'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend'],
+    # 'DEFAULT_PERMISSION_CLASSES': [
+    #     'rest_framework.permissions.IsAuthenticated',
+    # ]
+}
+
+AUTHENTICATION_BACKENDS = [
+    'django.contrib.auth.backends.ModelBackend'
+]

+ 26 - 0
Django_test/urls.py

@@ -0,0 +1,26 @@
+"""Django_test URL Configuration
+
+The `urlpatterns` list routes URLs to views. For more information please see:
+    https://docs.djangoproject.com/en/3.0/topics/http/urls/
+Examples:
+Function views
+    1. Add an import:  from my_app import views
+    2. Add a URL to urlpatterns:  path('', views.home, name='home')
+Class-based views
+    1. Add an import:  from other_app.views import Home
+    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
+Including another URLconf
+    1. Import the include() function: from django.urls import include, path
+    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
+"""
+
+from django.conf.urls import url
+from django.contrib import admin
+from django.urls import path, include
+
+# 主入口请求出口
+urlpatterns = [
+    path('admin/', admin.site.urls),
+    url(r'^api-auth/', include('rest_framework.urls')),
+    url(r'work/', include('workreport.urls'))  # 使用workreport工作区的路由
+]

+ 16 - 0
Django_test/wsgi.py

@@ -0,0 +1,16 @@
+"""
+WSGI config for Django_test project.
+
+It exposes the WSGI callable as a module-level variable named ``application``.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
+"""
+
+import os
+
+from django.core.wsgi import get_wsgi_application
+
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Django_test.settings')
+
+application = get_wsgi_application()

+ 16 - 0
Pipfile

@@ -0,0 +1,16 @@
+[[source]]
+name = "pypi"
+url = "https://pypi.tuna.tsinghua.edu.cn/simple/"
+verify_ssl = true
+
+[dev-packages]
+
+[packages]
+mysqlclient = "*"
+djangorestframework = "*"
+djangorestframework-bulk = "*"
+django-filters = "*"
+django-filter = "*"
+
+[requires]
+python_version = "3.7"

+ 92 - 0
Pipfile.lock

@@ -0,0 +1,92 @@
+{
+    "_meta": {
+        "hash": {
+            "sha256": "a35e0523a27ca548a7f655a88207bf5f79832e6386522b2a8689c84d08e1a114"
+        },
+        "pipfile-spec": 6,
+        "requires": {
+            "python_version": "3.7"
+        },
+        "sources": [
+            {
+                "name": "pypi",
+                "url": "https://pypi.tuna.tsinghua.edu.cn/simple/",
+                "verify_ssl": true
+            }
+        ]
+    },
+    "default": {
+        "asgiref": {
+            "hashes": [
+                "sha256:7e51911ee147dd685c3c8b805c0ad0cb58d360987b56953878f8c06d2d1c6f1a",
+                "sha256:9fc6fb5d39b8af147ba40765234fa822b39818b12cc80b35ad9b0cef3a476aed"
+            ],
+            "markers": "python_version >= '3.5'",
+            "version": "==3.2.10"
+        },
+        "django": {
+            "hashes": [
+                "sha256:31a5fbbea5fc71c99e288ec0b2f00302a0a92c44b13ede80b73a6a4d6d205582",
+                "sha256:5457fc953ec560c5521b41fad9e6734a4668b7ba205832191bbdff40ec61073c"
+            ],
+            "markers": "python_version >= '3.6'",
+            "version": "==3.0.8"
+        },
+        "django-filter": {
+            "hashes": [
+                "sha256:11e63dd759835d9ba7a763926ffb2662cf8a6dcb4c7971a95064de34dbc7e5af",
+                "sha256:616848eab6fc50193a1b3730140c49b60c57a3eda1f7fc57fa8505ac156c6c75"
+            ],
+            "index": "pypi",
+            "version": "==2.3.0"
+        },
+        "django-filters": {
+            "hashes": [
+                "sha256:1a9799a41106dc53ed894e952a24e8dee9b4fb37f010f22d178c09c90c61d711"
+            ],
+            "index": "pypi",
+            "version": "==0.2.1"
+        },
+        "djangorestframework": {
+            "hashes": [
+                "sha256:05809fc66e1c997fd9a32ea5730d9f4ba28b109b9da71fccfa5ff241201fd0a4",
+                "sha256:e782087823c47a26826ee5b6fa0c542968219263fb3976ec3c31edab23a4001f"
+            ],
+            "index": "pypi",
+            "version": "==3.11.0"
+        },
+        "djangorestframework-bulk": {
+            "hashes": [
+                "sha256:39230d8379acebd86d313df6c9150cafecb636eae1d097c30a26389ab9fee5b1"
+            ],
+            "index": "pypi",
+            "version": "==0.2.1"
+        },
+        "mysqlclient": {
+            "hashes": [
+                "sha256:3f39855a4ad22805361e782cc4d1010ac74796225fa2d1c03cc16673ccdc983a",
+                "sha256:a6b5648f648b16335e3b1aaec93dc3fcc81a9a661180e306936437cc522c810b",
+                "sha256:edd42ccaa444b00702d5374b2f5f7585c9d0ce201917f15339f1c3cf91c1b1ed",
+                "sha256:fb2f75aea14722390d2d8ddf384ad99da708c707a96656210a7be8af20a2c5e5"
+            ],
+            "index": "pypi",
+            "version": "==2.0.1"
+        },
+        "pytz": {
+            "hashes": [
+                "sha256:a494d53b6d39c3c6e44c3bec237336e14305e4f29bbf800b599253057fbb79ed",
+                "sha256:c35965d010ce31b23eeb663ed3cc8c906275d6be1a34393a1d73a41febf4a048"
+            ],
+            "version": "==2020.1"
+        },
+        "sqlparse": {
+            "hashes": [
+                "sha256:022fb9c87b524d1f7862b3037e541f68597a730a8843245c349fc93e1643dc4e",
+                "sha256:e162203737712307dfe78860cc56c8da8a852ab2ee33750e33aeadf38d12c548"
+            ],
+            "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
+            "version": "==0.3.1"
+        }
+    },
+    "develop": {}
+}

+ 3 - 0
README.md

@@ -0,0 +1,3 @@
+# Python Django
+Django入门
+使用Django框架

BIN
__pycache__/manage.cpython-37.pyc


+ 0 - 0
db.sqlite3


+ 21 - 0
manage.py

@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+"""Django's command-line utility for administrative tasks."""
+import os
+import sys
+
+
+def main():
+    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Django_test.settings')
+    try:
+        from django.core.management import execute_from_command_line
+    except ImportError as exc:
+        raise ImportError(
+            "Couldn't import Django. Are you sure it's installed and "
+            "available on your PYTHONPATH environment variable? Did you "
+            "forget to activate a virtual environment?"
+        ) from exc
+    execute_from_command_line(sys.argv)
+
+
+if __name__ == '__main__':
+    main()

+ 0 - 0
workreport/__init__.py


BIN
workreport/__pycache__/__init__.cpython-37.pyc


BIN
workreport/__pycache__/admin.cpython-37.pyc


BIN
workreport/__pycache__/models.cpython-37.pyc


BIN
workreport/__pycache__/serializex.cpython-37.pyc


BIN
workreport/__pycache__/urls.cpython-37.pyc


BIN
workreport/__pycache__/views.cpython-37.pyc


+ 3 - 0
workreport/admin.py

@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.

+ 5 - 0
workreport/apps.py

@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class WorkreportConfig(AppConfig):
+    name = 'workreport'

+ 32 - 0
workreport/migrations/0001_initial.py

@@ -0,0 +1,32 @@
+# Generated by Django 3.0.8 on 2020-07-16 04:30
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    initial = True
+
+    dependencies = [
+        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='DailyReport',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('title', models.CharField(max_length=50)),
+                ('content', models.TextField()),
+                ('creat_at', models.DateTimeField(auto_now=True)),
+                ('creat_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
+            ],
+            options={
+                'verbose_name': '工作汇报',
+                'verbose_name_plural': '工作汇报列表',
+                'db_table': 'workreport_daily',
+            },
+        ),
+    ]

+ 0 - 0
workreport/migrations/__init__.py


BIN
workreport/migrations/__pycache__/0001_initial.cpython-37.pyc


BIN
workreport/migrations/__pycache__/__init__.cpython-37.pyc


+ 18 - 0
workreport/models.py

@@ -0,0 +1,18 @@
+from django.contrib.auth.models import User
+from django.db import models
+
+
+# Create your models here.
+class DailyReport(models.Model):
+    # 生成的所有字段
+    title = models.CharField(max_length=50)
+    content = models.TextField()
+    # auto_now 自动得到当前时间
+    creat_at = models.DateTimeField(auto_now=True)
+    creat_by = models.ForeignKey(User, blank=True, null=True, on_delete=models.CASCADE)
+
+    class Meta:
+        app_label = 'workreport'
+        db_table = 'workreport_daily'
+        verbose_name = '工作汇报'
+        verbose_name_plural = '工作汇报列表'

+ 10 - 0
workreport/serializex.py

@@ -0,0 +1,10 @@
+from rest_framework import serializers
+
+from workreport.models import DailyReport
+
+
+class DailyReportSerializex(serializers.ModelSerializer):
+    # 默认返回
+    class Meta:
+        model = DailyReport
+        fields = '__all__'

+ 3 - 0
workreport/tests.py

@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.

+ 19 - 0
workreport/urls.py

@@ -0,0 +1,19 @@
+# 添加路由
+
+from django.conf.urls import url
+from rest_framework_bulk.routes import BulkRouter
+
+from workreport.views import ReportView, DailyReportView, LoginView, LogoutView
+
+router = BulkRouter()
+router.register(r'dailyreport', DailyReportView)
+router.register(r'dailyreport1', DailyReportView)
+
+urlpatterns = router.urls
+
+urlpatterns += [
+    url(r'report/', ReportView.as_view()),
+    url(r'login/', LoginView.as_view()),
+    url(r'logout/', LogoutView.as_view())
+
+]

+ 84 - 0
workreport/views.py

@@ -0,0 +1,84 @@
+from django.contrib.auth import login, logout
+from django.contrib.auth.backends import ModelBackend
+from django.shortcuts import render
+
+# Create your views here.
+from rest_framework import status, permissions
+from rest_framework.decorators import permission_classes
+from rest_framework.response import Response
+from rest_framework.views import APIView
+from rest_framework.viewsets import ModelViewSet
+from workreport.models import DailyReport
+
+# api接口调用方法
+from workreport.serializex import DailyReportSerializex
+
+
+class ReportView(APIView):
+    # get 请求
+    def get(self, request):
+        # 取字段
+        data = DailyReport \
+            .objects \
+            .values().all()
+
+        # .values('title', 'content', 'creat_at', 'creat_by', 'id')
+        # 返回请求 数据和请求状态
+        return Response(data=data, status=status.HTTP_200_OK)
+
+    # post 请求
+    def post(self, request):
+        # DailyReport
+        data = request.data
+        # 存入数据库
+        # 设置保存内容
+        report = DailyReport(
+            title=data['title'],
+            content=data['content'],
+            creat_by_id=data['creat_by_id'],
+        )
+        report.save()  # 执行了保存操作
+        return Response(status=status.HTTP_201_CREATED)
+
+    # delete 请求
+    def delete(self, request):
+        data = request.data
+        report = DailyReport \
+            .objects \
+            .filter(creat_by_id=data['creat_by_id']) \
+            .delete()
+
+        return Response(data=report, status=status.HTTP_200_OK)
+
+    # update 请求
+    def put(self, request):
+        data = request.data
+        report = DailyReport \
+            .objects \
+            .filter(creat_by_id=data['creat_by_id']) \
+            .update(content="改变内容")
+        return Response(data=report, status=status.HTTP_200_OK)
+
+
+class DailyReportView(ModelViewSet):
+    queryset = DailyReport.objects.all()
+    serializer_class = DailyReportSerializex
+    filter_fields = {'title': ['exact']}
+
+
+@permission_classes((permissions.AllowAny,))
+class LoginView(APIView):
+    def post(self, request):
+        data = request.data
+        user = ModelBackend().authenticate(username=data['username'], password=data['password'], request=request)
+        if user is None:
+            return Response(data={'msg': '用户名或密码不正确'}, status=status.HTTP_404_NOT_FOUND)
+        else:
+            login(request, user=user, backend='django.contrib.auth.backends.ModelBackend')
+        return Response(status=status.HTTP_200_OK)
+
+
+class LogoutView(APIView):
+    def post(self, request):
+        logout(request)
+        return Response(data={'msg': 'logout success!'}, status=status.HTTP_200_OK)