Closed pavelsolar closed 3 years ago
Please provide your current version (can be found on the system page since v0.8.4) Version: 0.14.2
When I try to import recipe from any website, I always get following error.
An error occurred while trying to import this recipe!<!DOCTYPE html>
'servings'
['/opt/recipes', '/opt/recipes/venv/bin', '/usr/local/lib/python38.zip', '/usr/local/lib/python3.8', '/usr/local/lib/python3.8/lib-dynload', '/opt/recipes/venv/lib/python3.8/site-packages']
/opt/recipes/venv/lib/python3.8/site-packages/django/core/handlers/exception.py
response = await sync_to_async(response_for_exception, thread_sensitive=False)(request, exc)
return response
return inner
else:
@wraps(get_response)
def inner(request):
try:
response = get_response(request)
except Exception as exc:
response = response_for_exception(request, exc)
KeyError('servings')
<bound method BaseHandler._get_response of <django.core.handlers.wsgi.WSGIHandler object at 0x7f3d6d1553a0>>
<WSGIRequest: POST '/data/import/url'>
/opt/recipes/venv/lib/python3.8/site-packages/django/core/handlers/base.py
if response is None:
wrapped_callback = self.make_view_atomic(callback)
# If it is an asynchronous view, run it in a subthread.
if asyncio.iscoroutinefunction(wrapped_callback):
wrapped_callback = async_to_sync(wrapped_callback)
response = wrapped_callback(request, *callback_args, callback_kwargs)
except Exception as e:
response = self.process_exception_by_middleware(e, request)
raise
# Complain if the view returned None (a common error).
<function import_url at 0x7f3d6b8df820>
()
{}
<bound method CsrfViewMiddleware.process_view of <django.middleware.csrf.CsrfViewMiddleware object at 0x7f3d6d126370>>
None
<django.core.handlers.wsgi.WSGIHandler object at 0x7f3d6d1553a0>
/opt/recipes/venv/lib/python3.8/site-packages/django/contrib/auth/decorators.py
that takes the user object and returns True if the user passes.
"""
def decorator(view_func):
@wraps(view_func)
def _wrapped_view(request, *args, *kwargs):
if test_func(request.user):
return view_func(request, args, kwargs)
path = request.build_absolute_uri()
resolved_login_url = resolve_url(login_url or settings.LOGIN_URL)
# If the login url is the same scheme and net location then just
# use the path as the "next" url.
login_scheme, login_netloc = urlparse(resolved_login_url)[:2]
current_scheme, current_netloc = urlparse(path)[:2]
'view_no_group'
'next'
<function group_required.<locals>.in_groups at 0x7f3d6b8df4c0>
<function import_url at 0x7f3d6b8df790>
/usr/local/lib/python3.8/contextlib.py
return self
def call(self, func):
@wraps(func)
def inner(*args, kwds):
with self._recreate_cm():
return func(*args, **kwds)
class _GeneratorContextManagerBase:
"""Shared functionality for @contextmanager and @asynccontextmanager."""
(<WSGIRequest: POST '/data/import/url'>,)
<function import_url at 0x7f3d6b8df700>
<django.db.transaction.Atomic object at 0x7f3d6b8cd2b0>
/opt/recipes/cookbook/views/data.py
if request.method == 'POST':
data = json.loads(request.body)
recipe = Recipe.objects.create(
name=data['name'],
waiting_time=data['cookTime'],
working_time=data['prepTime'],
servings=data['servings'],
internal=True,
created_by=request.user,
)
step = Step.objects.create(
instruction=data['recipeInstructions'],
{'all_keywords': False, 'cookTime': 0, 'image': 'https://www.kucharkaprodceru.cz/wp-content/uploads/2018/02/lasagne-recept.jpg', 'keywords': [], 'name': 'Lasagne', 'prepTime': 0, 'recipeIngredient': [{'amount': 0, 'ingredient': {'id': 44714, 'text': 'špetka soli'}, 'note': '', 'original': 'špetka soli', 'unit': {'id': 41613, 'text': ''}}, {'amount': 500, 'ingredient': {'id': 14218, 'text': 'mléka'}, 'note': '', 'original': '500 ml mléka', 'unit': {'id': 56698, 'text': 'ml'}}, {'amount': 2, 'ingredient': {'id': 99917, 'text': 'lžíce hladké mouky'}, 'note': '', 'original': '2 vrchovatá lžíce hladké mouky', 'unit': {'id': 22420, 'text': 'vrchovatá'}}, {'amount': 2, 'ingredient': {'id': 95331, 'text': '1 lžíce másla'}, 'note': '', 'original': '2 + 1 lžíce másla', 'unit': {'id': 97392, 'text': '+'}}, {'amount': 200, 'ingredient': {'id': 15931, 'text': 'čerstvé mozzarelly'}, 'note': '', 'original': '200 g čerstvé mozzarelly', 'unit': {'id': 76480, 'text': 'g'}}, {'amount': 50, 'ingredient': {'id': 49848, 'text': 'strouhaného parmazánu'}, 'note': '', 'original': '50 g strouhaného parmazánu', 'unit': {'id': 10400, 'text': 'g'}}, {'amount': 2, 'ingredient': {'id': 90184, 'text': 'boloňské omáčky'}, 'note': '', 'original': '2 dávky boloňské omáčky ', 'unit': {'id': 64790, 'text': 'dávky'}}, {'amount': 350, 'ingredient': {'id': 93519, 'text': 'suchých lasagní'}, 'note': '', 'original': '350 g suchých lasagní', 'unit': {'id': 89800, 'text': 'g'}}, {'amount': 0, 'ingredient': {'id': 63919, 'text': 'špetka čerstvě nastrouhaného ' 'muškátového květu nebo oříšku'}, 'note': '', 'original': 'špetka čerstvě nastrouhaného muškátového ' 'květu nebo oříšku', 'unit': {'id': 28474, 'text': ''}}], 'recipeInstructions': 'Nejprve uvařte boloňskou omáčku podle samostatného ' 'receptu.\n' 'Jakmile bude omáčka témeř dovařená a bude jí chybět už ' 'jen posledních 30 minut, pusťte se do přípravy ' 'bešamelu: V kastrůlku rozehřejte 2 lžíce másla, ' 'jakmile se rozpustí a zabublá, vsypte mouku, nechte ' 'zpěnit a minutu intenzivně míchejte metličkou, aby se ' 'mouka nepřipálila. Postupně v několika dávkách začněte ' 'přilévat studené mléko a obsah kastrůlku přitom ' 'důkladně dál prošlehávejte metličkou. Vše přiveďte k ' 'mírnému varu, osolte, okořeňte a nechte pozvolna 15 ' 'minut vařit. Každou chvíli omáčku promíchejte, mouka i ' 'mléko se snadno připalují. Hotovou omáčku odstavte a ' 'vmíchejte do ní lžíci másla.\n' 'Troubu začněte předehřívat na 180 stupňů. Na dno formy ' 'na pečení nebo hran… <trimmed 5501 bytes string>
PavelS
No GET data
No POST data
No FILES data
'cs'
'1%7Ck4DUty9RxXyIx0REQ9Q8uYba3VebfxMOcnWeZd6fbMPQis5kvigCzDw2u86d%7C%242y%2410%24CMRwimde4KSw4BDlAGruQe2cMqo0WdZfIHUYFMe5nxtxvk3z1nR5C'
'http%3A//192.168.100.100/mwnew/admin/view%3Apackages'
'1.1.1063777497.1611343617'
'51173a59-cbf0-418f-8a0f-c51fdd6b91a0'
'GA1.1.1307133437.1611343617'
'1'
'1aab99ac91c6918e4fdf5b40dcf67be2'
'UGF2ZWxT'
'YacAjlZxf2xwn7IgiwlmBws76nwZVu3cp2vorx3v4ChVGvCTKw'
'0'
'PavelS'
'n71tkswl'
'cf77036f-afef-45a1-8590-1bca6b3e0cbc'
'1613676562769'
'PiblGI9pQblF3Sq4fpbn3f4XtUT887pVhHpv6O9MD1FI54byMlJJOybFwag08a0R'
'ozhm10yalb8ep6dk5y4sq28s7c0d44n0'
'en'
'3415'
'application/json;charset=UTF-8'
'application/json, text/plain, /'
'gzip, deflate'
'cs,en;q=0.9,sk;q=0.8,de;q=0.7,pl;q=0.6'
'keep-alive'
('lang=cs; ' 'remember_web_59ba36addc2b2f9401580f014c7f58ea4e30989d=1%7Ck4DUty9RxXyIx0REQ9Q8uYba3VebfxMOcnWeZd6fbMPQis5kvigCzDw2u86d%7C%242y%2410%24CMRwimde4KSw4BDlAGruQe2cMqo0WdZfIHUYFMe5nxtxvk3z1nR5C; ' 'back_to_admin=http%3A//192.168.100.100/mwnew/admin/view%3Apackages; ' '_gcl_au=1.1.1063777497.1611343617; ' '_hjid=51173a59-cbf0-418f-8a0f-c51fdd6b91a0; _ga=GA1.1.1307133437.1611343617; ' 'remeber=1; qtoken=1aab99ac91c6918e4fdf5b40dcf67be2; qtoken_account=UGF2ZWxT; ' 'grocy_session=YacAjlZxf2xwn7IgiwlmBws76nwZVu3cp2vorx3v4ChVGvCTKw; ' 'NAS_PW_STATUS=0; NAS_USER=PavelS; NAS_SID=n71tkswl; home=1; ' 'nas_1_u=UGF2ZWxT; session=cf77036f-afef-45a1-8590-1bca6b3e0cbc; ' 'QT=1613676562769; ' 'csrftoken=PiblGI9pQblF3Sq4fpbn3f4XtUT887pVhHpv6O9MD1FI54byMlJJOybFwag08a0R; ' 'sessionid=ozhm10yalb8ep6dk5y4sq28s7c0d44n0; django_language=en')
'192.168.100.100:32794'
'http://192.168.100.100:32794'
'http://192.168.100.100:32794/data/import/url'
('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like ' 'Gecko) Chrome/88.0.4324.150 Safari/537.36')
'**'
'XMLHttpRequest'
'/data/import/url'
''
'192.168.100.108'
'49558'
'POST'
'0.0.0.0'
'8080'
'HTTP/1.1'
'gunicorn/20.0.4'
<socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('10.0.3.3', 8080), raddr=('192.168.100.108', 49558)>
<gunicorn.http.wsgi.WSGIErrorsWrapper object at 0x7f3d6a4c97f0>
<class 'gunicorn.http.wsgi.FileWrapper'>
<gunicorn.http.body.Body object at 0x7f3d6a4c91f0>
True
False
'http'
(1, 0)
recipes.settings
'cookbook.helper.AllAuthCustomAdapter'
[]
['*']
['django.contrib.auth.backends.ModelBackend', 'allauth.account.auth_backends.AuthenticationBackend']
'auth.User'
'/opt/recipes'
{'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}}
'default'
'****'
600
'bootstrap4'
31449600
'csrftoken'
'/'
'Lax'
'django.views.csrf.csrf_failure'
'HTTP_X_CSRFTOKEN'
{'default': {'ATOMIC_REQUESTS': False, 'AUTOCOMMIT': True, 'CONN_MAX_AGE': 0, 'ENGINE': 'django.db.backends.sqlite3', 'HOST': None, 'NAME': 'db.sqlite3', 'OPTIONS': {}, 'PASSWORD': '****', 'PORT': None, 'TEST': {'CHARSET': None, 'COLLATION': None, 'MIGRATE': True, 'MIRROR': None, 'NAME': None}, 'TIME_ZONE': None, 'USER': None}}
2621440
1000
'N j, Y, P'
['%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M:%S.%f', '%Y-%m-%d %H:%M', '%m/%d/%Y %H:%M:%S', '%m/%d/%Y %H:%M:%S.%f', '%m/%d/%Y %H:%M', '%m/%d/%y %H:%M:%S', '%m/%d/%y %H:%M:%S.%f', '%m/%d/%y %H:%M']
'N j, Y'
['%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']
'.'
'utf-8'
'django.views.debug.ExceptionReporter'
'django.views.debug.SafeExceptionReporterFilter'
'django.core.files.storage.FileSystemStorage'
'sha256'
8
'cookbook/templates/generic/table_template.html'
'django.core.mail.backends.smtp.EmailBackend'
'localhost'
25
'[Django] '
['django.core.files.uploadhandler.MemoryFileUploadHandler', 'django.core.files.uploadhandler.TemporaryFileUploadHandler']
420
0
'django.forms.renderers.DjangoTemplates'
['dal', 'dal_select2', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.sites', 'django.contrib.staticfiles', 'django_tables2', 'django_filters', 'crispy_forms', 'emoji_picker', 'rest_framework', 'rest_framework.authtoken', 'django_cleanup.apps.CleanupConfig', 'webpack_loader', 'django_js_reverse', 'allauth', 'allauth.account', 'allauth.socialaccount', 'cookbook.apps.CookbookConfig']
['127.0.0.1']
'/opt/recipes/cookbook/static/django_js_reverse'
[('ca', 'Catalan'), ('cs', 'Czech'), ('nl', 'Dutch'), ('en', 'English'), ('fr', 'French'), ('de', 'German'), ('it', 'Italian'), ('lv', 'Latvian'), ('es', 'Spanish')]
['he', 'ar', 'ar-dz', 'fa', 'ur']
'django_language'
'logging.config.dictConfig'
'index'
'/accounts/login/'
'/opt/recipes/mediafiles'
'/media/'
'django.contrib.messages.storage.fallback.FallbackStorage'
{40: 'danger'}
['django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', '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.locale.LocaleMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']
'F j'
{'DEFAULT_AUTHENTICATION_CLASSES': ('rest_framework.authentication.SessionAuthentication', 'rest_framework.authentication.TokenAuthentication', 'rest_framework.authentication.BasicAuthentication'), 'DEFAULT_PERMISSION_CLASSES': ['rest_framework.permissions.IsAuthenticated']}
'recipes.urls'
('HTTP_X_FORWARDED_PROTO', 'https')
'same-origin'
31536000
'sessionid'
'django.contrib.sessions.backends.db'
'django.contrib.sessions.serializers.JSONSerializer'
'recipes.settings'
5
'm/d/Y P'
'm/d/Y'
'django.core.signing.TimestampSigner'
1
['django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder']
'whitenoise.storage.CompressedManifestStaticFilesStorage'
'/opt/recipes/staticfiles'
'/static/'
[{'APP_DIRS': True, 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': ['/opt/recipes/templates', '/opt/recipes/cookbook/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', 'django.template.context_processors.media']}}]
'django.test.runner.DiscoverRunner'
','
'P'
['%H:%M:%S', '%H:%M:%S.%f', '%H:%M']
'Europe/Berlin'
'/opt/recipes/vue'
{'DEFAULT': {'BUNDLE_DIR_NAME': 'vue/', 'CACHE': False, 'IGNORE': ['.+\.hot-update.js', '.+\.map'], 'POLL_INTERVAL': 0.1, 'STATS_FILE': '/opt/recipes/vue/webpack-stats.json', 'TIMEOUT': None}}
'recipes.wsgi.application'
'DENY'
'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.
DEBUG = True
should be fixed with 0.14.3
Version
Please provide your current version (can be found on the system page since v0.8.4) Version: 0.14.2
Bug description
When I try to import recipe from any website, I always get following error.
An error occurred while trying to import this recipe!<!DOCTYPE html>
KeyError at /data/import/url
Traceback Switch to copy-and-paste view
/opt/recipes/venv/lib/python3.8/site-packages/django/core/handlers/exception.py
, line 47, in inner/opt/recipes/venv/lib/python3.8/site-packages/django/core/handlers/base.py
, line 181, in _get_response/opt/recipes/venv/lib/python3.8/site-packages/django/contrib/auth/decorators.py
, line 21, in _wrapped_view/usr/local/lib/python3.8/contextlib.py
, line 75, in inner/opt/recipes/cookbook/views/data.py
, line 125, in import_urlRequest information
USER
PavelS
GET
No GET data
POST
No POST data
FILES
No FILES data
COOKIES
META
Settings
Using settings module
recipes.settings
You're seeing this error because you have
DEBUG = True
in your Django settings file. Change that toFalse
, and Django will display a standard page generated by the handler for this status code.