Нет смотрящий матч не в том месте? - PullRequest
0 голосов
/ 06 апреля 2019

Я пытаюсь создать ссылку на приложение на своем веб-сайте из базового шаблона, используя теги шаблона django, но он продолжает искать в неправильном приложении, и я не знаю почему.

Вот код моего базового html-файла:

<!DOCTYPE html>
<html>
<head>
    <title>kinbank</title>
    {% block head %}{% endblock %}
</head>
<body>
    <div>
       <div class="page-width"> 
           <h1 class="top-org-name">
            </h1>
               <div class="nav">
                <a href="{% url 'home:index' %}">Home</a>
                <a href="{% url 'languages:index' %}">Languages</a>
            </div>
                <div class="clear">
            </div>
       </div>
    </div>
{% block content %}{% endblock %}
</body>

и файл базовых URL

urlpatterns = [
    path('languages/', include('languages.urls')),
    path('home/', include('home.urls')),
    path('admin/', admin.site.urls),
]

Странно, что домашняя ссылка работает, а языковая - нет.

Я получаю ошибку:

TemplateSyntaxError at /home/

Но в этой строке возникает ошибка

<a href="{% url 'languages:index' %}">Languages</a>

Вот трассировка:

Traceback:

File "/Users/sp16194/.local/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
  34.             response = get_response(request)

File "/Users/sp16194/.local/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
  126.                 response = self.process_exception_by_middleware(e, request)

File "/Users/sp16194/.local/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
  124.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/Users/sp16194/Desktop/Projects_Git/kinbank3/kinbank/home/views.py" in index
  18.   return HttpResponse(template.render(context, request))

File "/Users/sp16194/.local/lib/python3.5/site-packages/django/template/backends/django.py" in render
  61.             return self.template.render(context)

File "/Users/sp16194/.local/lib/python3.5/site-packages/django/template/base.py" in render
  171.                     return self._render(context)

File "/Users/sp16194/.local/lib/python3.5/site-packages/django/template/base.py" in _render
  163.         return self.nodelist.render(context)

File "/Users/sp16194/.local/lib/python3.5/site-packages/django/template/base.py" in render
  937.                 bit = node.render_annotated(context)

File "/Users/sp16194/.local/lib/python3.5/site-packages/django/template/base.py" in render_annotated
  904.             return self.render(context)

File "/Users/sp16194/.local/lib/python3.5/site-packages/django/template/loader_tags.py" in render
  127.         compiled_parent = self.get_parent(context)

File "/Users/sp16194/.local/lib/python3.5/site-packages/django/template/loader_tags.py" in get_parent
  124.         return self.find_template(parent, context)

File "/Users/sp16194/.local/lib/python3.5/site-packages/django/template/loader_tags.py" in find_template
  104.             template_name, skip=history,

File "/Users/sp16194/.local/lib/python3.5/site-packages/django/template/engine.py" in find_template
  126.                 template = loader.get_template(name, skip=skip)

File "/Users/sp16194/.local/lib/python3.5/site-packages/django/template/loaders/base.py" in get_template
  30.                     contents, origin, origin.template_name, self.engine,

File "/Users/sp16194/.local/lib/python3.5/site-packages/django/template/base.py" in __init__
  156.         self.nodelist = self.compile_nodelist()

File "/Users/sp16194/.local/lib/python3.5/site-packages/django/template/base.py" in compile_nodelist
  194.             return parser.parse()

File "/Users/sp16194/.local/lib/python3.5/site-packages/django/template/base.py" in parse
  478.                     raise self.error(token, e)

File "/Users/sp16194/.local/lib/python3.5/site-packages/django/template/base.py" in parse
  476.                     compiled_result = compile_func(self, token)

File "/Users/sp16194/.local/lib/python3.5/site-packages/django/template/defaulttags.py" in url
  1375.             args.append(parser.compile_filter(value))

File "/Users/sp16194/.local/lib/python3.5/site-packages/django/template/base.py" in compile_filter
  563.         return FilterExpression(token, self)

File "/Users/sp16194/.local/lib/python3.5/site-packages/django/template/base.py" in __init__
  663.                                       "from '%s'" % (token[upto:], token))

Exception Type: TemplateSyntaxError at /home/
Exception Value: Could not parse the remainder: '=' from '='

1 Ответ

2 голосов
/ 06 апреля 2019

установите имя приложения в urls.py вашего языкового приложения следующим образом

app_name = languages

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...