jinja2.exceptions.UndefinedError: 'None' has no attribute 'price'
__call__
yield chunk
else:
break
start_response('200 OK', [('Content-Type', 'text/css')])
return read_file(os.path.join(package_dir, result))
return self.app(environ, start_response)
@staticmethod
def quote_css_string(s):
"""Quotes a string as CSS string literal."""
return "'" + ''.join('\\%06x' % ord(c) for c in s) + "'"
wsgi_app
try:
ctx.push()
response = self.full_dispatch_request()
except Exception as e:
error = e
response = self.handle_exception(e)
except: # noqa: B001
error = sys.exc_info()[1]
raise
return response(environ, start_response)
finally:
wsgi_app
ctx = self.request_context(environ)
error: t.Optional[BaseException] = None
try:
try:
ctx.push()
response = self.full_dispatch_request()
except Exception as e:
error = e
response = self.handle_exception(e)
except: # noqa: B001
error = sys.exc_info()[1]
full_dispatch_request
request_started.send(self)
rv = self.preprocess_request()
if rv is None:
rv = self.dispatch_request()
except Exception as e:
rv = self.handle_user_exception(e)
return self.finalize_request(rv)
def finalize_request(
self,
rv: t.Union[ft.ResponseReturnValue, HTTPException],
full_dispatch_request
try:
request_started.send(self)
rv = self.preprocess_request()
if rv is None:
rv = self.dispatch_request()
except Exception as e:
rv = self.handle_user_exception(e)
return self.finalize_request(rv)
def finalize_request(
dispatch_request
and req.method == "OPTIONS"
):
return self.make_default_options_response()
# otherwise dispatch to the handler for that endpoint
view_args: t.Dict[str, t.Any] = req.view_args # type: ignore[assignment]
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
def full_dispatch_request(self) -> Response:
"""Dispatches the request and on top of that performs request
pre and postprocessing as well as HTTP exception catching and
error handling.
product
return render_template('product.html', happy='Данные успешно отправленны', red=red, catid=catid, bread=bread, categories=categories, ind=ind, now=now, contacts=contacts)
except:
return 'Произошла ошибка'
else:
return render_template('product.html', error='Пожалуйста заполните все формы', red=red, catid=catid, bread=bread, categories=categories, ind=ind, now=now, contacts=contacts)
return render_template('product.html', red=red, catid=catid, bread=bread, categories=categories, ind=ind, now=now, contacts=contacts)
@app.route('/cases', methods = ['POST', 'GET'])
def cases():
cases = Cases.query.all()
render_template
a list is given, the first name to exist will be rendered.
:param context: The variables to make available in the template.
"""
app = current_app._get_current_object() # type: ignore[attr-defined]
template = app.jinja_env.get_or_select_template(template_name_or_list)
return _render(app, template, context)
def render_template_string(source: str, **context: t.Any) -> str:
"""Render a template from the given source string with the given
context.
_render
def _render(app: "Flask", template: Template, context: t.Dict[str, t.Any]) -> str:
app.update_template_context(context)
before_render_template.send(app, template=template, context=context)
rv = template.render(context)
template_rendered.send(app, template=template, context=context)
return rv
def render_template(
render
ctx = self.new_context(dict(*args, **kwargs))
try:
return self.environment.concat(self.root_render_func(ctx)) # type: ignore
except Exception:
self.environment.handle_exception()
async def render_async(self, *args: t.Any, **kwargs: t.Any) -> str:
"""This works similar to :meth:`render` but returns a coroutine
that when awaited returns the entire rendered template string. This
requires the async feature to be enabled.
handle_exception
"""Exception handling helper. This is used internally to either raise
rewritten exceptions or return a rendered traceback for the template.
"""
from .debug import rewrite_traceback_stack
raise rewrite_traceback_stack(source=source)
def join_path(self, template: str, parent: str) -> str:
"""Join a template with the parent. By default all the lookups are
relative to the loader root so this method returns the `template`
parameter unchanged, but if the paths should be relative to the
top-level template code
{% extends 'layout.html' %}
{% block title %}{{bread.title}}{% endblock %}
{% block description %}{{bread.description}}{% endblock %}
{% block body %}
top-level template code
</div>
</div>
{% block body %}
{% endblock %}
block 'body'
<div class="intro_text">{{bread.intro | safe}}</div>
<button class="open_pop_up offbutton">Перезвоните мне</button>
</div>
{% if bread.price[0] %}
<div class="row_price">
<div class="price">
<h3>Прайс</h3>
<div class="ann"><p>Наименование:</p> <p>Цена:</p></div>
getitem
def getitem(
self, obj: t.Any, argument: t.Union[str, t.Any]
) -> t.Union[t.Any, Undefined]:
"""Get an item or attribute of an object but prefer the item."""
try:
return obj[argument]
except (AttributeError, TypeError, LookupError):
if isinstance(argument, str):
try:
attr = str(argument)
except Exception:
jinja2.exceptions.UndefinedError: 'None' has no attribute 'price'
This is the Copy/Paste friendly version of the traceback.
The console is locked and needs to be unlocked by entering the PIN. You can find the PIN printed out on the standard output of your shell that runs the server.