Closed lprivette closed 4 years ago
Error:
KeyError at /events/ 'event' Request Method: POST Request URL: https://whispersdev.wim.usgs.gov/whispersservices/events/ Django Version: 2.2.13 Python Executable: /usr/bin/python3 Python Version: 3.5.2 Python Path: ['/var/www/whispersservices_django', '/var/www/whispersservices_django/env/lib/python35.zip', '/var/www/whispersservices_django/env/lib/python3.5', '/var/www/whispersservices_django/env/lib/python3.5/plat-x86_64-linux-gnu', '/var/www/whispersservices_django/env/lib/python3.5/lib-dynload', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/var/www/whispersservices_django/env/lib/python3.5/site-packages'] Server time: Thu, 18 Jun 2020 18:17:04 +0000 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'simple_history', 'rest_framework', 'corsheaders', 'dry_rest_permissions', 'django_filters', 'whispersservices'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'simple_history.middleware.HistoryRequestMiddleware']
JSON:
{ "event_reference": "", "event_type": "1", "complete": false, "public": true, "staff": null, "event_status": "1", "legal_status": 1, "legal_number": "", "new_organizations": [ null ], "new_service_request": { "request_type": 0, "new_comments": [] }, "new_event_diagnoses": [], "new_comments": [], "new_eventgroups": [], "new_event_locations": [ { "name": "", "start_date": "2020-06-01", "end_date": "2020-06-10", "country": "30", "administrative_level_one": 8, "administrative_level_two": 317, "latitude": null, "longitude": null, "land_ownership": "2", "gnis_name": "Nationals Park", "gnis_id": "2400509", "site_description": "", "history": "test", "environmental_factors": "", "clinical_signs": "", "comment": "", "new_location_species": [ { "species": 131, "population_count": 5, "sick_count": 0, "dead_count": 0, "sick_count_estimated": 1, "dead_count_estimated": 1, "priority": null, "captive": false, "age_bias": null, "sex_bias": null, "new_species_diagnoses": [] } ], "new_location_contacts": [ { "contact": 5529, "contact_type": 4 } ] } ], "new_read_collaborators": [], "new_write_collaborators": [], "quality_check": null }
TRACEBACK:
File "/var/www/whispersservices_django/env/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner 34. response = get_response(request) File "/var/www/whispersservices_django/env/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response 115. response = self.process_exception_by_middleware(e, request) File "/var/www/whispersservices_django/env/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response 113. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/var/www/whispersservices_django/env/lib/python3.5/site-packages/django/views/decorators/csrf.py" in wrapped_view 54. return view_func(*args, **kwargs) File "/var/www/whispersservices_django/env/lib/python3.5/site-packages/rest_framework/viewsets.py" in view 116. return self.dispatch(request, *args, **kwargs) File "/var/www/whispersservices_django/env/lib/python3.5/site-packages/rest_framework/views.py" in dispatch 509. response = self.handle_exception(exc) File "/var/www/whispersservices_django/env/lib/python3.5/site-packages/rest_framework/views.py" in handle_exception 469. self.raise_uncaught_exception(exc) File "/var/www/whispersservices_django/env/lib/python3.5/site-packages/rest_framework/views.py" in raise_uncaught_exception 480. raise exc File "/var/www/whispersservices_django/env/lib/python3.5/site-packages/rest_framework/views.py" in dispatch 506. response = handler(request, *args, **kwargs) File "/var/www/whispersservices_django/env/lib/python3.5/site-packages/rest_framework/mixins.py" in create 19. self.perform_create(serializer) File "/var/www/whispersservices_django/whispersservices/views.py" in perform_create 156. serializer.save(created_by=self.request.user, modified_by=self.request.user) File "/var/www/whispersservices_django/env/lib/python3.5/site-packages/rest_framework/serializers.py" in save 204. self.instance = self.create(validated_data) File "/var/www/whispersservices_django/whispersservices/serializers.py" in create 913. if evt_loc_serializer.is_valid(): File "/var/www/whispersservices_django/env/lib/python3.5/site-packages/rest_framework/serializers.py" in is_valid 219. self._validated_data = self.run_validation(self.initial_data) File "/var/www/whispersservices_django/env/lib/python3.5/site-packages/rest_framework/serializers.py" in run_validation 421. value = self.validate(value) File "/var/www/whispersservices_django/whispersservices/serializers.py" in validate 1801. if data['event'].complete and 'FULL_EVENT_CHAIN_CREATE' not in self.initial_data: Exception Type: KeyError at /events/ Exception Value: 'event' Request information: USER: lprivette_usgs GET: No GET data POST: No POST data FILES: No FILES data COOKIES: No cookie data META: CONTENT_LENGTH = '1476' CONTENT_TYPE = 'application/json' CONTEXT_DOCUMENT_ROOT = '/var/www/whispersdev' CONTEXT_PREFIX = '' DOCUMENT_ROOT = '/var/www/whispersdev' GATEWAY_INTERFACE = 'CGI/1.1' HTTP_ACCEPT = 'application/json' HTTP_ACCEPT_ENCODING = 'gzip, deflate, br' HTTP_ACCEPT_LANGUAGE = 'en-US,en;q=0.9' HTTP_AUTHORIZATION = 'Basic bHByaXZldHRlX3VzZ3M6d2hpc3BlcnNsYXVyZW4hMA==' HTTP_CONNECTION = 'keep-alive' HTTP_HOST = 'whispersdev.wim.usgs.gov' HTTP_ORIGIN = 'http://localhost:4200' HTTP_REFERER = 'http://localhost:4200/eventsubmission' HTTP_SEC_FETCH_DEST = 'empty' HTTP_SEC_FETCH_MODE = 'cors' HTTP_SEC_FETCH_SITE = 'cross-site' HTTP_USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36' PATH_INFO = '/events/' PATH_TRANSLATED = '/var/www/whispersdev/events/' QUERY_STRING = '' REMOTE_ADDR = '71.163.133.166' REMOTE_PORT = '59130' REQUEST_METHOD = 'POST' REQUEST_SCHEME = 'https' REQUEST_URI = '/whispersservices/events/' SCRIPT_FILENAME = '/var/www/whispersservices_django/whispersservices_django/wsgi.py' SCRIPT_NAME = '/whispersservices' SERVER_ADDR = '10.0.1.14' SERVER_ADMIN = '[no address given]' SERVER_NAME = 'whispersdev.wim.usgs.gov' SERVER_PORT = '443' SERVER_PROTOCOL = 'HTTP/1.1' SERVER_SIGNATURE = '<address>Apache/2.4.18 (Ubuntu) Server at whispersdev.wim.usgs.gov Port 443</address>\n' SERVER_SOFTWARE = 'Apache/2.4.18 (Ubuntu)' SSL_TLS_SNI = 'whispersdev.wim.usgs.gov' apache.version = '(2, 4, 18)' mod_wsgi.application_group = 'whispersdev.wim.usgs.gov|/whispersservices' mod_wsgi.callable_object = 'application' mod_wsgi.daemon_connects = '1' mod_wsgi.daemon_restarts = '0' mod_wsgi.daemon_start = '1592504223530897' mod_wsgi.enable_sendfile = '0' mod_wsgi.handler_script = '' mod_wsgi.ignore_activity = '0' mod_wsgi.listener_host = '' mod_wsgi.listener_port = '443' mod_wsgi.path_info = '/events/' mod_wsgi.process_group = 'dev' mod_wsgi.queue_start = '1592504223530776' mod_wsgi.request_handler = 'wsgi-script' mod_wsgi.request_id = 'cv6LyI/Diz0' mod_wsgi.request_start = '1592504223530610' mod_wsgi.script_name = '/whispersservices' mod_wsgi.script_reloading = '1' mod_wsgi.script_start = '1592504223530999' mod_wsgi.thread_id = 6 mod_wsgi.thread_requests = 49 mod_wsgi.total_requests = 312 mod_wsgi.version = '(4, 7, 1)' wsgi.errors = <_io.TextIOWrapper name='<wsgi.errors>' encoding='utf-8'> wsgi.file_wrapper = '' wsgi.input = <mod_wsgi.Input object at 0x7f131dd7dce0> wsgi.input_terminated = True wsgi.multiprocess = False wsgi.multithread = True wsgi.run_once = False wsgi.url_scheme = 'https' wsgi.version = '(1, 0)' Settings: Using settings module whispersservices_django.settings ABSOLUTE_URL_OVERRIDES = {} ADMINS = [] ADMIN_ENABLED = False ALLOWED_HOSTS = ['whispersdev.wim.usgs.gov', '52.3.161.36', '10.0.1.14', '127.0.0.1', 'localhost'] APPEND_SLASH = True APP_WHISPERS_URL = 'https://whispersdev.wim.usgs.gov/whispers/' AUTHENTICATION_BACKENDS = ['django.contrib.auth.backends.ModelBackend'] AUTH_PASSWORD_VALIDATORS = '********************' AUTH_USER_MODEL = 'whispersservices.User' BASE_DIR = '/var/www/whispersservices_django' CACHES = {'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}} CACHE_MIDDLEWARE_ALIAS = 'default' CACHE_MIDDLEWARE_KEY_PREFIX = '********************' CACHE_MIDDLEWARE_SECONDS = 600 CELERY_BROKER_URL = 'amqp://localhost' CELERY_IMPORTS = ['whispersservices.immediate_tasks', 'whispersservices.scheduled_tasks'] CELERY_RESULT_BACKEND = 'rpc://' CONFIG = <configparser.RawConfigParser object at 0x7f132c014668> CORS_ORIGIN_ALLOW_ALL = True CSRF_COOKIE_AGE = 31449600 CSRF_COOKIE_DOMAIN = None CSRF_COOKIE_HTTPONLY = False CSRF_COOKIE_NAME = 'csrftoken' CSRF_COOKIE_PATH = '/' CSRF_COOKIE_SAMESITE = 'Lax' CSRF_COOKIE_SECURE = False CSRF_FAILURE_VIEW = 'django.views.csrf.csrf_failure' CSRF_HEADER_NAME = 'HTTP_X_CSRFTOKEN' CSRF_TRUSTED_ORIGINS = [] CSRF_USE_SESSIONS = False DATABASES = {'default': {'AUTOCOMMIT': True, 'OPTIONS': {}, 'PORT': '5432', 'NAME': 'whispersdev', 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'PASSWORD': '********************', 'USER': 'nwhcadmin', 'TIME_ZONE': None, 'CONN_MAX_AGE': 60, 'ATOMIC_REQUESTS': False, 'HOST': 'nwhc.ck2zppz9pgsw.us-east-1.rds.amazonaws.com', 'TEST': {'COLLATION': None, 'NAME': None, 'CHARSET': None, 'MIRROR': None}}} DATABASE_ROUTERS = [] DATA_UPLOAD_MAX_MEMORY_SIZE = 2621440 DATA_UPLOAD_MAX_NUMBER_FIELDS = 1000 DATETIME_FORMAT = 'N j, Y, P' DATETIME_INPUT_FORMATS = ['%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M:%S.%f', '%Y-%m-%d %H:%M', '%Y-%m-%d', '%m/%d/%Y %H:%M:%S', '%m/%d/%Y %H:%M:%S.%f', '%m/%d/%Y %H:%M', '%m/%d/%Y', '%m/%d/%y %H:%M:%S', '%m/%d/%y %H:%M:%S.%f', '%m/%d/%y %H:%M', '%m/%d/%y'] DATE_FORMAT = 'N j, Y' DATE_INPUT_FORMATS = ['%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', '%b %d %Y', '%b %d, %Y', '%d %b %Y', '%d %b, %Y', '%B %d %Y', '%B %d, %Y', '%d %B %Y', '%d %B, %Y'] DEBUG = True DEBUG_PROPAGATE_EXCEPTIONS = False DECIMAL_SEPARATOR = '.' DEFAULT_CHARSET = 'utf-8' DEFAULT_CONTENT_TYPE = 'text/html' DEFAULT_EXCEPTION_REPORTER_FILTER = 'django.views.debug.SafeExceptionReporterFilter' DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage' DEFAULT_FROM_EMAIL = 'whispers@usgs.gov' DEFAULT_INDEX_TABLESPACE = '' DEFAULT_TABLESPACE = '' DISALLOWED_USER_AGENTS = [] EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.usgs.gov' EMAIL_HOST_PASSWORD = '********************' EMAIL_HOST_USER = 'whispers@usgs.gov' EMAIL_NWHC_EPI = 'nwhc-epi@usgs.gov' EMAIL_PORT = '25' EMAIL_SSL_CERTFILE = None EMAIL_SSL_KEYFILE = '********************' EMAIL_SUBJECT_PREFIX = '[Django] ' EMAIL_TIMEOUT = 180 EMAIL_USE_LOCALTIME = False EMAIL_USE_SSL = False EMAIL_USE_TLS = True EMAIL_WHISPERS = 'whispers@usgs.gov' ENVIRONMENT = 'development' FILE_CHARSET = 'utf-8' FILE_UPLOAD_DIRECTORY_PERMISSIONS = None FILE_UPLOAD_HANDLERS = ['django.core.files.uploadhandler.MemoryFileUploadHandler', 'django.core.files.uploadhandler.TemporaryFileUploadHandler'] FILE_UPLOAD_MAX_MEMORY_SIZE = 2621440 FILE_UPLOAD_PERMISSIONS = None FILE_UPLOAD_TEMP_DIR = None FIRST_DAY_OF_WEEK = 0 FIXTURE_DIRS = [] FORCE_SCRIPT_NAME = None FORMAT_MODULE_PATH = None FORM_RENDERER = 'django.forms.renderers.DjangoTemplates' GEONAMES_USERNAME = 'nwhcwhispers' IGNORABLE_404_URLS = [] INSTALLED_APPS = ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'simple_history', 'rest_framework', 'corsheaders', 'dry_rest_permissions', 'django_filters', 'whispersservices'] INTERNAL_IPS = [] LANGUAGES = [('af', 'Afrikaans'), ('ar', 'Arabic'), ('ast', 'Asturian'), ('az', 'Azerbaijani'), ('bg', 'Bulgarian'), ('be', 'Belarusian'), ('bn', 'Bengali'), ('br', 'Breton'), ('bs', 'Bosnian'), ('ca', 'Catalan'), ('cs', 'Czech'), ('cy', 'Welsh'), ('da', 'Danish'), ('de', 'German'), ('dsb', 'Lower Sorbian'), ('el', 'Greek'), ('en', 'English'), ('en-au', 'Australian English'), ('en-gb', 'British English'), ('eo', 'Esperanto'), ('es', 'Spanish'), ('es-ar', 'Argentinian Spanish'), ('es-co', 'Colombian Spanish'), ('es-mx', 'Mexican Spanish'), ('es-ni', 'Nicaraguan Spanish'), ('es-ve', 'Venezuelan Spanish'), ('et', 'Estonian'), ('eu', 'Basque'), ('fa', 'Persian'), ('fi', 'Finnish'), ('fr', 'French'), ('fy', 'Frisian'), ('ga', 'Irish'), ('gd', 'Scottish Gaelic'), ('gl', 'Galician'), ('he', 'Hebrew'), ('hi', 'Hindi'), ('hr', 'Croatian'), ('hsb', 'Upper Sorbian'), ('hu', 'Hungarian'), ('hy', 'Armenian'), ('ia', 'Interlingua'), ('id', 'Indonesian'), ('io', 'Ido'), ('is', 'Icelandic'), ('it', 'Italian'), ('ja', 'Japanese'), ('ka', 'Georgian'), ('kab', 'Kabyle'), ('kk', 'Kazakh'), ('km', 'Khmer'), ('kn', 'Kannada'), ('ko', 'Korean'), ('lb', 'Luxembourgish'), ('lt', 'Lithuanian'), ('lv', 'Latvian'), ('mk', 'Macedonian'), ('ml', 'Malayalam'), ('mn', 'Mongolian'), ('mr', 'Marathi'), ('my', 'Burmese'), ('nb', 'Norwegian Bokmål'), ('ne', 'Nepali'), ('nl', 'Dutch'), ('nn', 'Norwegian Nynorsk'), ('os', 'Ossetic'), ('pa', 'Punjabi'), ('pl', 'Polish'), ('pt', 'Portuguese'), ('pt-br', 'Brazilian Portuguese'), ('ro', 'Romanian'), ('ru', 'Russian'), ('sk', 'Slovak'), ('sl', 'Slovenian'), ('sq', 'Albanian'), ('sr', 'Serbian'), ('sr-latn', 'Serbian Latin'), ('sv', 'Swedish'), ('sw', 'Swahili'), ('ta', 'Tamil'), ('te', 'Telugu'), ('th', 'Thai'), ('tr', 'Turkish'), ('tt', 'Tatar'), ('udm', 'Udmurt'), ('uk', 'Ukrainian'), ('ur', 'Urdu'), ('vi', 'Vietnamese'), ('zh-hans', 'Simplified Chinese'), ('zh-hant', 'Traditional Chinese')] LANGUAGES_BIDI = ['he', 'ar', 'fa', 'ur'] LANGUAGE_CODE = 'en-us' LANGUAGE_COOKIE_AGE = None LANGUAGE_COOKIE_DOMAIN = None LANGUAGE_COOKIE_NAME = 'django_language' LANGUAGE_COOKIE_PATH = '/' LOCALE_PATHS = [] LOGGING = {} LOGGING_CONFIG = 'logging.config.dictConfig' LOGIN_REDIRECT_URL = '/accounts/profile/' LOGIN_URL = '/accounts/login/' LOGOUT_REDIRECT_URL = None MANAGERS = [] MEDIA_ROOT = '/var/www/whispersservices_django/media' MEDIA_URL = '/media/' MESSAGE_STORAGE = 'django.contrib.messages.storage.fallback.FallbackStorage' MIDDLEWARE = ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'simple_history.middleware.HistoryRequestMiddleware'] MIGRATION_MODULES = {} MONTH_DAY_FORMAT = 'F j' NUMBER_GROUPING = 0 PASSWORD_HASHERS = '********************' PASSWORD_RESET_TIMEOUT_DAYS = '********************' PREPEND_WWW = False PROJECT_PATH = '/var/www/whispersservices_django' REST_FRAMEWORK = {'DEFAULT_AUTHENTICATION_CLASSES': ('rest_framework.authentication.BasicAuthentication', 'rest_framework.authentication.SessionAuthentication')} ROOT_URLCONF = 'whispersservices_django.urls' SECRET_KEY = '********************' SECURE_BROWSER_XSS_FILTER = False SECURE_CONTENT_TYPE_NOSNIFF = False SECURE_HSTS_INCLUDE_SUBDOMAINS = False SECURE_HSTS_PRELOAD = False SECURE_HSTS_SECONDS = 0 SECURE_PROXY_SSL_HEADER = None SECURE_REDIRECT_EXEMPT = [] SECURE_SSL_HOST = None SECURE_SSL_REDIRECT = False SERVER_EMAIL = 'root@localhost' SESSION_CACHE_ALIAS = 'default' SESSION_COOKIE_AGE = 1209600 SESSION_COOKIE_DOMAIN = None SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_NAME = 'sessionid' SESSION_COOKIE_PATH = '/' SESSION_COOKIE_SAMESITE = 'Lax' SESSION_COOKIE_SECURE = False SESSION_ENGINE = 'django.contrib.sessions.backends.db' SESSION_EXPIRE_AT_BROWSER_CLOSE = True SESSION_FILE_PATH = None SESSION_SAVE_EVERY_REQUEST = False SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer' SETTINGS_DIR = '/var/www/whispersservices_django/whispersservices_django' SETTINGS_MODULE = 'whispersservices_django.settings' SHORT_DATETIME_FORMAT = 'm/d/Y P' SHORT_DATE_FORMAT = 'm/d/Y' SIGNING_BACKEND = 'django.core.signing.TimestampSigner' SILENCED_SYSTEM_CHECKS = [] SSL_CERT = '/var/www/whispersservices_django/whispersservices_django/ca-bundle.crt' STATICFILES_DIRS = "('/var/www/whispersservices_django/static/staticfiles',)" STATICFILES_FINDERS = ['django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder'] STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage' STATIC_PATH = '/var/www/whispersservices_django/static/staticfiles' STATIC_ROOT = '/var/www/whispersservices_django/static' STATIC_URL = '/static/' TEMPLATES = [{'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']}, 'APP_DIRS': True, 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': ['/var/www/whispersservices_django/templates']}] TEMPLATE_PATH = '/var/www/whispersservices_django/templates' TEST_NON_SERIALIZED_APPS = [] TEST_RUNNER = 'django.test.runner.DiscoverRunner' THOUSAND_SEPARATOR = ',' TIME_FORMAT = 'P' TIME_INPUT_FORMATS = ['%H:%M:%S', '%H:%M:%S.%f', '%H:%M'] TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_THOUSAND_SEPARATOR = False USE_TZ = True USE_X_FORWARDED_HOST = False USE_X_FORWARDED_PORT = False WSGI_APPLICATION = 'whispersservices_django.wsgi.application' X_FRAME_OPTIONS = 'SAMEORIGIN' YEAR_MONTH_FORMAT = 'F Y' You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard page generated by the handler for this status code.
Thanks. Turns out the new approach to serilalizers broke the way I had set up the 'FULL_EVENT_CHAIN_CREATE', which is now fixed in a56130ce.
Error:
JSON:
TRACEBACK: