临时代码

detached
RogerWork 1 year ago
parent eeb74fba8d
commit 368dfcc8d5
  1. 0
      common/__init__.py
  2. 9
      common/base_model.py
  3. 21
      dingxin_toolbox_drf/settings.py
  4. 6
      dingxin_toolbox_drf/urls.py
  5. 143
      logs/dingxin.log
  6. BIN
      reqirement.txt
  7. 33
      update/migrations/0001_initial.py
  8. 28
      update/migrations/0002_rename_num_cinema_inner_id_rename_code_cinema_zz_num_and_more.py
  9. 23
      update/models.py
  10. 8
      update/serializers.py
  11. 27
      update/urls.py
  12. 13
      update/views.py

@ -0,0 +1,9 @@
from django.db import models
# Create your models here.
class BaseModels(models.Model):
update_time = models.DateTimeField(auto_now=True, verbose_name="最后更新时间")
class Meta:
abstract = True # 设置为抽象类

@ -16,7 +16,7 @@ import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
print(BASE_DIR)
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
@ -28,7 +28,6 @@ DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
@ -39,10 +38,12 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'corsheaders',
'update',
]
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
@ -72,7 +73,6 @@ TEMPLATES = [
WSGI_APPLICATION = 'dingxin_toolbox_drf.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
@ -87,7 +87,6 @@ DATABASES = {
}
}
# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
@ -106,7 +105,6 @@ AUTH_PASSWORD_VALIDATORS = [
},
]
# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/
@ -118,7 +116,6 @@ USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/
@ -156,7 +153,7 @@ LOGGING = {
'file': {
'level': 'INFO',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(os.path.dirname(BASE_DIR), "logs/dingxin.log"),
'filename': os.path.join(BASE_DIR, "logs/dingxin.log"),
'maxBytes': 300 * 1024 * 1024,
'backupCount': 10,
'formatter': 'verbose'
@ -168,4 +165,12 @@ LOGGING = {
'propagate': True,
},
}
}
}
REST_FRAMEWORK = {
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema' # 配置接口文档
}
# 跨域配置
CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_ALLOW_ALL = True

@ -15,8 +15,12 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import path, include
from rest_framework.documentation import include_docs_urls
urlpatterns = [
path('admin/', admin.site.urls),
path('docs/', include_docs_urls(title='接口文档')),
path('update/', include('update.urls')),
]

@ -0,0 +1,143 @@
INFO 2023-11-06 14:37:19,819 autoreload 668 Watching for file changes with StatReloader
INFO 2023-11-06 14:37:43,555 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\update\views.py changed, reloading.
INFO 2023-11-06 14:37:44,254 autoreload 668 Watching for file changes with StatReloader
INFO 2023-11-06 14:42:37,111 autoreload 668 Watching for file changes with StatReloader
INFO 2023-11-06 14:45:50,810 basehttp 212 "GET /update/cinema_list HTTP/1.1" 301 0
ERROR 2023-11-06 14:45:50,967 log 241 Internal Server Error: /update/cinema_list/
Traceback (most recent call last):
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\django\core\handlers\exception.py", line 55, in inner
response = get_response(request)
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\django\core\handlers\base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\django\views\decorators\csrf.py", line 56, in wrapper_view
return view_func(*args, **kwargs)
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\rest_framework\viewsets.py", line 125, in view
return self.dispatch(request, *args, **kwargs)
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\rest_framework\views.py", line 509, in dispatch
response = self.handle_exception(exc)
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\rest_framework\views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\rest_framework\views.py", line 480, in raise_uncaught_exception
raise exc
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\rest_framework\views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\rest_framework\mixins.py", line 46, in list
return Response(serializer.data)
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\rest_framework\serializers.py", line 768, in data
ret = super().data
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\rest_framework\serializers.py", line 253, in data
self._data = self.to_representation(self.instance)
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\rest_framework\serializers.py", line 686, in to_representation
return [
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\rest_framework\serializers.py", line 687, in <listcomp>
self.child.to_representation(item) for item in iterable
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\rest_framework\serializers.py", line 507, in to_representation
for field in fields:
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\rest_framework\serializers.py", line 368, in _readable_fields
for field in self.fields.values():
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\django\utils\functional.py", line 57, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\rest_framework\serializers.py", line 356, in fields
for key, value in self.get_fields().items():
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\rest_framework\serializers.py", line 1076, in get_fields
field_class, field_kwargs = self.build_field(
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\rest_framework\serializers.py", line 1222, in build_field
return self.build_unknown_field(field_name, model_class)
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\rest_framework\serializers.py", line 1340, in build_unknown_field
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Field name `zz_unm` is not valid for model `Cinema`.
ERROR 2023-11-06 14:45:50,972 basehttp 212 "GET /update/cinema_list/ HTTP/1.1" 500 142370
INFO 2023-11-06 14:46:27,105 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\update\serializers.py changed, reloading.
INFO 2023-11-06 14:46:27,828 autoreload 668 Watching for file changes with StatReloader
INFO 2023-11-06 14:46:30,166 basehttp 212 "GET /update/cinema_list HTTP/1.1" 301 0
INFO 2023-11-06 14:46:30,240 basehttp 212 "GET /update/cinema_list/ HTTP/1.1" 200 195
INFO 2023-11-06 14:47:04,749 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\update\serializers.py changed, reloading.
INFO 2023-11-06 14:47:05,528 autoreload 668 Watching for file changes with StatReloader
INFO 2023-11-06 14:47:07,205 basehttp 212 "GET /update/cinema_list HTTP/1.1" 301 0
INFO 2023-11-06 14:47:07,311 basehttp 212 "GET /update/cinema_list/ HTTP/1.1" 200 237
INFO 2023-11-06 14:48:54,964 basehttp 212 "GET /update/cinema_list HTTP/1.1" 301 0
INFO 2023-11-06 14:48:55,045 basehttp 212 "GET /update/cinema_list/ HTTP/1.1" 200 237
ERROR 2023-11-06 14:51:28,028 log 241 Internal Server Error: /update/cinema_add
Traceback (most recent call last):
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\django\core\handlers\exception.py", line 55, in inner
response = get_response(request)
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\django\utils\deprecation.py", line 136, in __call__
response = self.process_response(request, response)
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\django\middleware\common.py", line 108, in process_response
return self.response_redirect_class(self.get_full_path_with_slash(request))
File "D:\Code\Work\Python\dingxin_toolbox_drf\venv\lib\site-packages\django\middleware\common.py", line 87, in get_full_path_with_slash
raise RuntimeError(
RuntimeError: You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to 127.0.0.1:8000/update/cinema_add/?name=%E9%BC%8E%E6%96%B0%E6%B5%8B%E8%AF%95%E5%BD%B1%E9%99%A23.111&ip=172.16.3.111&zz_num=15033211&inner_id=1994&db_user=test&db_pwd=cine123456&sys_ver=2.0.33.0333.ZZ&client_ver=2.033.0333.8876 (note the trailing slash), or set APPEND_SLASH=False in your Django settings.
ERROR 2023-11-06 14:51:28,032 basehttp 212 "POST /update/cinema_add?name=%E9%BC%8E%E6%96%B0%E6%B5%8B%E8%AF%95%E5%BD%B1%E9%99%A23.111&ip=172.16.3.111&zz_num=15033211&inner_id=1994&db_user=test&db_pwd=cine123456&sys_ver=2.0.33.0333.ZZ&client_ver=2.033.0333.8876 HTTP/1.1" 500 73469
WARNING 2023-11-06 14:53:04,947 log 241 Bad Request: /update/cinema_add/
WARNING 2023-11-06 14:53:04,948 basehttp 212 "POST /update/cinema_add/?name=%E9%BC%8E%E6%96%B0%E6%B5%8B%E8%AF%95%E5%BD%B1%E9%99%A23.111&ip=172.16.3.111&zz_num=15033211&inner_id=1994&db_user=test&db_pwd=cine123456&sys_ver=2.0.33.0333.ZZ&client_ver=2.033.0333.8876 HTTP/1.1" 400 307
INFO 2023-11-06 14:55:18,648 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\dingxin_toolbox_drf\settings.py changed, reloading.
INFO 2023-11-06 14:55:19,380 autoreload 668 Watching for file changes with StatReloader
WARNING 2023-11-06 14:55:52,641 log 241 Bad Request: /update/cinema_add/
WARNING 2023-11-06 14:55:52,642 basehttp 212 "POST /update/cinema_add/?name=%E9%BC%8E%E6%96%B0%E6%B5%8B%E8%AF%95%E5%BD%B1%E9%99%A23.111&ip=172.16.3.111&zz_num=15033211&inner_id=1994&db_user=test&db_pwd=cine123456&sys_ver=2.0.33.0333.ZZ&client_ver=2.033.0333.8876 HTTP/1.1" 400 307
WARNING 2023-11-06 14:55:57,429 log 241 Not Found: /update/cinema_add
WARNING 2023-11-06 14:55:57,430 basehttp 212 "POST /update/cinema_add?name=%E9%BC%8E%E6%96%B0%E6%B5%8B%E8%AF%95%E5%BD%B1%E9%99%A23.111&ip=172.16.3.111&zz_num=15033211&inner_id=1994&db_user=test&db_pwd=cine123456&sys_ver=2.0.33.0333.ZZ&client_ver=2.033.0333.8876 HTTP/1.1" 404 3194
INFO 2023-11-06 14:59:30,054 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\dingxin_toolbox_drf\settings.py changed, reloading.
INFO 2023-11-06 14:59:30,895 autoreload 668 Watching for file changes with StatReloader
WARNING 2023-11-06 14:59:35,689 log 241 Bad Request: /update/cinema_add/
WARNING 2023-11-06 14:59:35,690 basehttp 212 "POST /update/cinema_add/?name=%E9%BC%8E%E6%96%B0%E6%B5%8B%E8%AF%95%E5%BD%B1%E9%99%A23.111&ip=172.16.3.111&zz_num=15033211&inner_id=1994&db_user=test&db_pwd=cine123456&sys_ver=2.0.33.0333.ZZ&client_ver=2.033.0333.8876 HTTP/1.1" 400 307
INFO 2023-11-06 15:00:32,104 basehttp 212 "POST /update/cinema_add/ HTTP/1.1" 201 245
INFO 2023-11-06 15:11:09,895 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\update\urls.py changed, reloading.
INFO 2023-11-06 15:11:10,555 autoreload 668 Watching for file changes with StatReloader
WARNING 2023-11-06 15:12:06,419 log 241 Not Found: /cinema_get/1
WARNING 2023-11-06 15:12:06,419 basehttp 212 "GET /cinema_get/1 HTTP/1.1" 404 2233
WARNING 2023-11-06 15:12:39,762 log 241 Not Found: /cinema_get/id=1
WARNING 2023-11-06 15:12:39,763 basehttp 212 "GET /cinema_get/id=1 HTTP/1.1" 404 2244
WARNING 2023-11-06 15:13:03,164 log 241 Not Found: /cinema_get/
WARNING 2023-11-06 15:13:03,165 basehttp 212 "GET /cinema_get/?id=1 HTTP/1.1" 404 2235
WARNING 2023-11-06 15:13:16,655 log 241 Not Found: /cinema_get/1/
WARNING 2023-11-06 15:13:16,656 basehttp 212 "GET /cinema_get/1/ HTTP/1.1" 404 2236
WARNING 2023-11-06 15:13:50,462 log 241 Not Found: /cinema_get/1/
WARNING 2023-11-06 15:13:50,463 basehttp 212 "GET /cinema_get/1/ HTTP/1.1" 404 2236
INFO 2023-11-06 15:13:50,712 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\update\urls.py changed, reloading.
INFO 2023-11-06 15:13:51,428 autoreload 668 Watching for file changes with StatReloader
WARNING 2023-11-06 15:13:54,686 log 241 Not Found: /cinema_get/1/
WARNING 2023-11-06 15:13:54,687 basehttp 212 "GET /cinema_get/1/ HTTP/1.1" 404 2236
WARNING 2023-11-06 15:14:06,994 log 241 Not Found: /cinema_get/1/
WARNING 2023-11-06 15:14:06,994 basehttp 212 "GET /cinema_get/1/ HTTP/1.1" 404 2236
INFO 2023-11-06 15:19:54,783 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\update\views.py changed, reloading.
INFO 2023-11-06 15:19:55,630 autoreload 668 Watching for file changes with StatReloader
INFO 2023-11-06 15:22:18,859 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\update\views.py changed, reloading.
INFO 2023-11-06 15:22:19,588 autoreload 668 Watching for file changes with StatReloader
INFO 2023-11-06 15:24:02,900 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\update\urls.py changed, reloading.
INFO 2023-11-06 15:24:03,590 autoreload 668 Watching for file changes with StatReloader
INFO 2023-11-06 15:24:39,978 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\update\urls.py changed, reloading.
INFO 2023-11-06 15:24:40,729 autoreload 668 Watching for file changes with StatReloader
WARNING 2023-11-06 15:24:48,590 log 241 Not Found: /cinema_get/1/
WARNING 2023-11-06 15:24:48,591 basehttp 212 "GET /cinema_get/1/ HTTP/1.1" 404 2236
INFO 2023-11-06 16:15:26,635 autoreload 668 Watching for file changes with StatReloader
INFO 2023-11-06 16:15:36,746 basehttp 212 "GET /docs HTTP/1.1" 301 0
WARNING 2023-11-06 16:15:36,814 log 241 Forbidden: /docs/
WARNING 2023-11-06 16:15:36,815 basehttp 212 "GET /docs/ HTTP/1.1" 403 5137
INFO 2023-11-06 16:15:37,406 basehttp 212 "GET /static/rest_framework/css/prettify.css HTTP/1.1" 200 817
INFO 2023-11-06 16:15:37,413 basehttp 212 "GET /static/rest_framework/css/bootstrap.min.css HTTP/1.1" 200 121457
INFO 2023-11-06 16:15:37,431 basehttp 212 "GET /static/rest_framework/css/bootstrap-tweaks.css HTTP/1.1" 200 3385
INFO 2023-11-06 16:15:37,434 basehttp 212 "GET /static/rest_framework/css/default.css HTTP/1.1" 200 1152
INFO 2023-11-06 16:15:37,441 basehttp 212 "GET /static/rest_framework/js/csrf.js HTTP/1.1" 200 1719
INFO 2023-11-06 16:15:37,448 basehttp 212 "GET /static/rest_framework/js/ajax-form.js HTTP/1.1" 200 3597
INFO 2023-11-06 16:15:37,463 basehttp 212 "GET /static/rest_framework/js/default.js HTTP/1.1" 200 1268
INFO 2023-11-06 16:15:37,471 basehttp 212 "GET /static/rest_framework/js/bootstrap.min.js HTTP/1.1" 200 39680
INFO 2023-11-06 16:15:37,477 basehttp 212 "GET /static/rest_framework/js/prettify-min.js HTTP/1.1" 200 13632
INFO 2023-11-06 16:15:37,490 basehttp 212 "GET /static/rest_framework/js/jquery-3.5.1.min.js HTTP/1.1" 200 89476
INFO 2023-11-06 16:15:37,563 basehttp 212 "GET /static/rest_framework/img/grid.png HTTP/1.1" 200 1458
WARNING 2023-11-06 16:15:38,141 log 241 Not Found: /favicon.ico
WARNING 2023-11-06 16:15:38,142 basehttp 212 "GET /favicon.ico HTTP/1.1" 404 2335
WARNING 2023-11-06 16:15:52,602 log 241 Forbidden: /docs/
WARNING 2023-11-06 16:15:52,603 basehttp 212 "GET /docs/ HTTP/1.1" 403 5137
INFO 2023-11-06 16:17:45,996 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\dingxin_toolbox_drf\urls.py changed, reloading.
INFO 2023-11-06 16:17:46,703 autoreload 668 Watching for file changes with StatReloader
WARNING 2023-11-06 16:17:48,385 log 241 Forbidden: /docs/
WARNING 2023-11-06 16:17:48,386 basehttp 212 "GET /docs/ HTTP/1.1" 403 5230
INFO 2023-11-06 16:17:50,391 basehttp 212 "GET / HTTP/1.1" 200 5136
WARNING 2023-11-06 16:18:08,177 log 241 Forbidden: /docs/
WARNING 2023-11-06 16:18:08,178 basehttp 212 "GET /docs/ HTTP/1.1" 403 5230
INFO 2023-11-06 16:20:10,185 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\dingxin_toolbox_drf\urls.py changed, reloading.
INFO 2023-11-06 16:20:10,943 autoreload 668 Watching for file changes with StatReloader
INFO 2023-11-06 16:20:39,340 autoreload 668 Watching for file changes with StatReloader
WARNING 2023-11-06 16:20:47,290 log 241 Forbidden: /docs/
WARNING 2023-11-06 16:20:47,291 basehttp 212 "GET /docs/ HTTP/1.1" 403 5137

Binary file not shown.

@ -0,0 +1,33 @@
# Generated by Django 4.2.7 on 2023-11-06 02:54
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Cinema',
fields=[
('update_time', models.DateTimeField(auto_now=True, verbose_name='最后更新时间')),
('id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(max_length=100, verbose_name='影院名称')),
('ip', models.CharField(max_length=20, verbose_name='影院ip')),
('code', models.CharField(max_length=8, verbose_name='影院转账8位编码')),
('num', models.CharField(max_length=4, verbose_name='影院4位编码')),
('db_user', models.CharField(max_length=2, verbose_name='影院数据库账号')),
('db_pwd', models.CharField(max_length=50, verbose_name='影院数据库密码')),
('sys_ver', models.CharField(max_length=50, verbose_name='鼎新系统版本')),
('client_ver', models.CharField(max_length=50, verbose_name='鼎新客户端版本')),
],
options={
'verbose_name': '影院信息',
'db_table': 'update_cinema',
},
),
]

@ -0,0 +1,28 @@
# Generated by Django 4.2.7 on 2023-11-06 03:26
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('update', '0001_initial'),
]
operations = [
migrations.RenameField(
model_name='cinema',
old_name='num',
new_name='inner_id',
),
migrations.RenameField(
model_name='cinema',
old_name='code',
new_name='zz_num',
),
migrations.AlterField(
model_name='cinema',
name='db_user',
field=models.CharField(max_length=20, verbose_name='影院数据库账号'),
),
]

@ -1,3 +1,24 @@
from django.db import models
from common.base_model import BaseModels
# Create your models here.
class Cinema(BaseModels):
"""
影院信息表
"""
id = models.AutoField(primary_key=True)
name = models.CharField(verbose_name='影院名称', max_length=100, null=False)
ip = models.CharField(verbose_name='影院ip', max_length=20, null=False)
zz_num = models.CharField(verbose_name='影院转账8位编码', max_length=8, null=False)
inner_id = models.CharField(verbose_name="影院4位编码", max_length=4, null=False)
db_user = models.CharField(verbose_name='影院数据库账号', max_length=20, null=False)
db_pwd = models.CharField(verbose_name='影院数据库密码', max_length=50, null=False)
sys_ver = models.CharField(verbose_name='鼎新系统版本', max_length=50, null=False)
client_ver = models.CharField(verbose_name='鼎新客户端版本', max_length=50, null=False)
def __str__(self):
return self.ip
class Meta:
verbose_name = '影院信息'
db_table = 'update_cinema'

@ -0,0 +1,8 @@
from rest_framework import serializers, fields
from update.models import Cinema
class CinemaSerializer(serializers.ModelSerializer):
class Meta:
model = Cinema
fields = ('id', 'name', 'ip', 'zz_num', 'inner_id', 'db_user', 'db_pwd', 'sys_ver', 'client_ver', 'update_time')

@ -0,0 +1,27 @@
"""
URL configuration for dingxin_toolbox_drf project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.2/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.contrib import admin
from django.urls import path
from update import views
urlpatterns = [
path('cinema_list/', views.CinemaViewSet),
path('cinema_add/', views.CinemaViewSet),
path('cinema_get/<pk>/', views.CinemaViewSet),
path('cinema_update/<pk>/', views.CinemaViewSet),
path('cinema_delete/<pk>/', views.CinemaViewSet),
]

@ -1,3 +1,12 @@
from django.shortcuts import render
from rest_framework import viewsets, mixins
from update.models import Cinema
from update.serializers import CinemaSerializer
# Create your views here.
class CinemaViewSet(mixins.ListModelMixin,
mixins.RetrieveModelMixin,
mixins.CreateModelMixin,
mixins.UpdateModelMixin,
mixins.DestroyModelMixin):
queryset = Cinema.objects.all()
serializer_class = CinemaSerializer

Loading…
Cancel
Save