import time
from pprint import pprint
from django.forms import model_to_dict
from django.http import HttpResponse
from django.shortcuts import render
from django.db.models import F
from rest_framework.generics import RetrieveDestroyAPIView, RetrieveAPIView, ListAPIView, ListCreateAPIView, \
CreateAPIView
from rest_framework.decorators import action
from rest_framework.response import Response
from .models import Car, Mark
from .serializers import *
from datetime import datetime, timedelta
import json
import requests
django-1 | Internal Server Error: /api/china/car/create/
django-1 | Traceback (most recent call last):
django-1 | File "/usr/local/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
django-1 | response = get_response(request)
django-1 | ^^^^^^^^^^^^^^^^^^^^^
django-1 | File "/usr/local/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
django-1 | response = wrapped_callback(request, *callback_args, **callback_kwargs)
django-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-1 | File "/usr/local/lib/python3.11/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper
django-1 | return view_func(request, *args, **kwargs)
django-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-1 | File "/usr/local/lib/python3.11/site-packages/django/views/generic/base.py", line 104, in view
django-1 | return self.dispatch(request, *args, **kwargs)
django-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-1 | File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 509, in dispatch
django-1 | response = self.handle_exception(exc)
django-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
django-1 | File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 469, in handle_exception
django-1 | self.raise_uncaught_exception(exc)
django-1 | File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
django-1 | raise exc
django-1 | File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 506, in dispatch
django-1 | response = handler(request, *args, **kwargs)
django-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-1 | File "/usr/src/app/china/views.py", line 103, in post
django-1 | mark, created = Mark.objects.get_or_create(china_code=mark_name) # __icontains
django-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-1 | File "/usr/local/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method
django-1 | return getattr(self.get_queryset(), name)(*args, **kwargs)
django-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-1 | File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 948, in get_or_create
django-1 | return self.get(**kwargs), False
django-1 | ^^^^^^^^^^^^^^^^^^
django-1 | File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 635, in get
django-1 | clone = self._chain() if self.query.combinator else self.filter(*args, **kwargs)
django-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-1 | File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 1476, in filter
django-1 | return self._filter_or_exclude(False, args, kwargs)
django-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-1 | File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 1494, in _filter_or_exclude
django-1 | clone._filter_or_exclude_inplace(negate, args, kwargs)
django-1 | File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 1501, in _filter_or_exclude_inplace
nginx | 185.104.251.37 - - [07/Aug/2024:07:48:07 +0000] "POST /api/china/car/create/ HTTP/1.1" 500 140267 "-" "-" "-"
django-1 | self._query.add_q(Q(*args, **kwargs))
django-1 | File "/usr/local/lib/python3.11/site-packages/django/db/models/sql/query.py", line 1613, in add_q
django-1 | clause, _ = self._add_q(q_object, self.used_aliases)
django-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-1 | File "/usr/local/lib/python3.11/site-packages/django/db/models/sql/query.py", line 1645, in _add_q
django-1 | child_clause, needed_inner = self.build_filter(
django-1 | ^^^^^^^^^^^^^^^^^^
django-1 | File "/usr/local/lib/python3.11/site-packages/django/db/models/sql/query.py", line 1495, in build_filter
django-1 | lookups, parts, reffed_expression = self.solve_lookup_type(arg, summarize)
django-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-1 | File "/usr/local/lib/python3.11/site-packages/django/db/models/sql/query.py", line 1307, in solve_lookup_type
django-1 | _, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta())
django-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-1 | File "/usr/local/lib/python3.11/site-packages/django/db/models/sql/query.py", line 1772, in names_to_path
django-1 | raise FieldError(
django-1 | django.core.exceptions.FieldError: Cannot resolve keyword 'china_code' into field. Choices are: id, mark, model, name, sort_order
paths = []
def obxodFile(path, level=1):
global paths
# print('Level=', level)
if os.path.exists(path + "/log.txt"):
paths.append(str(path))
for i in os.listdir(path):
if os.path.isdir(path + "/" + i):
# print('Спускаемся', path + '/' + i)
obxodFile(path + "/" + i, level + 1)
# print('Возвращаемся в', path)