Я делаю рандом 3 статей из базы данных и добавить их в шаблон и данные из этого шаблона передать в другой шаблон с помощью include (короче: есть 1 шаблон со статьями и я пытаюся добавить эти статьи в другой шаблон при помощи include) и у меня появилося ошибка
Traceback:
File "D:\Users\MAestro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\backends\django.py" in render
61. return self.template.render(context)
File "D:\Users\MAestro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py" in render
171. return self._render(context)
File "D:\Users\MAestro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py" in _render
163. return self.nodelist.render(context)
File "D:\Users\MAestro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py" in render
937. bit = node.render_annotated(context)
File "D:\Users\MAestro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py" in render_annotated
904. return self.render(context)
File "D:\Users\MAestro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\loader_tags.py" in render
150. return compiled_parent._render(context)
File "D:\Users\MAestro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py" in _render
163. return self.nodelist.render(context)
File "D:\Users\MAestro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py" in render
937. bit = node.render_annotated(context)
File "D:\Users\MAestro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py" in render_annotated
904. return self.render(context)
File "D:\Users\MAestro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\loader_tags.py" in render
62. result = block.nodelist.render(context)
File "D:\Users\MAestro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py" in render
937. bit = node.render_annotated(context)
File "D:\Users\MAestro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py" in render_annotated
904. return self.render(context)
File "D:\Users\MAestro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\loader_tags.py" in render
176. template = context.template.engine.get_template(template_name)
File "D:\Users\MAestro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\engine.py" in get_template
143. template, origin = self.find_template(template_name)
File "D:\Users\MAestro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\engine.py" in find_template
129. raise TemplateDoesNotExist(name, tried=tried)
The above exception (randomArticle/randoms.html) was the direct cause of the following exception:
File "D:\Users\MAestro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\exception.py" in inner
34. response = get_response(request)
File "D:\Users\MAestro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\base.py" in _get_response
145. response = self.process_exception_by_middleware(e, request)
File "D:\Users\MAestro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\base.py" in _get_response
143. response = response.render()
File "D:\Users\MAestro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\response.py" in render
106. self.content = self.rendered_content
File "D:\Users\MAestro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\response.py" in rendered_content
83. content = template.render(context, self._request)
File "D:\Users\MAestro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\backends\django.py" in render
63. reraise(exc, self.backend)
File "D:\Users\MAestro\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\backends\django.py" in reraise
84. raise new from exc
Exception Type: TemplateDoesNotExist at /news/
Exception Value: randomArticle/randoms.html
1 шаблон куда добовляються статьи
{% include 'randomArticle/randoms.html' %}
randoms.html
{% for object in object_list %}
<a href="/programms/{{object.id}}"> <h1> {{object.title}} </h1> </a>
{% endfor %}
views.py
from django.views.generic import ListView, DetailView
# Create your views here.
from .news.models import Articles
class RandomDetail(DetailView):
model = Articles
template_name = 'randomArticle/random.html'
class RandomsList(ListView):
model = Articles
template_name = 'randomArticle/randoms.html'
def RandomArticles(request):
random_article = Articles.objects.order_by('?')[:3]
return render(request, 'randomArticle/randoms.html', {'random_article': random_article , 'posts':posts})
urls.py
urlpatterns=[
path('', RandomsList.as_view(), name='articles_list'),
path('<int:pk>/', RandomDetail.as_view(), name='article_detail'),
]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Айфон мало держит заряд, разбираемся с проблемой вместе с AppLab
Есть навбар в appcomponent
У меня есть солюшн с несколькими веб приложениями (aspnet mvc4) и библиотеками класов
EF Core - есть выборка из базы: