{"id":18386,"date":"2022-03-24T14:22:31","date_gmt":"2022-03-24T11:22:31","guid":{"rendered":"https:\/\/mob25.com\/?p=18386"},"modified":"2023-05-09T21:48:09","modified_gmt":"2023-05-09T18:48:09","slug":"django-vyvod-informacii-iz-bazy-dannyh","status":"publish","type":"post","link":"https:\/\/mob25.com\/blog\/django-vyvod-informacii-iz-bazy-dannyh\/","title":{"rendered":"Django &#8212; \u0432\u044b\u0432\u043e\u0434 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445"},"content":{"rendered":"\n<p>\u0417\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0411\u0414 \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u0438\u0437 \u043a\u043e\u0434\u0430 Python. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 Django ORM \u0435\u0441\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438\u0437 \u0411\u0414 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430<\/h3>\n\n\n\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435&nbsp;<code>posts\/views.py<\/code>&nbsp;\u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0435 view-\u0444\u0443\u043d\u043a\u0446\u0438\u044e&nbsp;<code>index()<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code><em># posts\/views.py<\/em>\nfrom django.http import HttpResponse\n<em># \u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043d\u0435\u0439<\/em>\nfrom .models import Post\n\ndef index(request):\n    <em># \u041e\u0434\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u044b\u0441\u044f\u0447\u0438 \u0441\u043b\u043e\u0432 \u043d\u0430 SQL:<\/em>\n    <em># \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e posts \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0430 \u0438\u0437 10 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438 Post,<\/em>\n    <em># \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u043f\u043e\u043b\u044e pub_date \u043f\u043e \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044e (\u043e\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043a \u043c\u0435\u043d\u044c\u0448\u0438\u043c)<\/em>\n    posts = Post.objects.order_by('-pub_date')[:10]\n    <em># \u0412 \u0441\u043b\u043e\u0432\u0430\u0440\u0435 context \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u0448\u0430\u0431\u043b\u043e\u043d<\/em>\n    context = {\n        'posts': posts,\n    }\n    return render(request, 'posts\/index.html', context) <\/code><\/pre>\n\n\n\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438&nbsp;<code>index()<\/code>&nbsp;\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f&nbsp;<code>posts<\/code>&nbsp;\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438&nbsp;<strong>Post<\/strong>&nbsp;\u0438\u0437 \u0411\u0414. \u041f\u043e\u0441\u043b\u0435 \u0438\u043c\u0435\u043d\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430&nbsp;<code>.objects<\/code>&nbsp;\u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0412 \u0437\u0430\u043f\u0440\u043e\u0441\u0435:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443&nbsp;<code>pub_date<\/code>&nbsp;\u043f\u043e \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044e, \u043e\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043a \u043c\u0435\u043d\u044c\u0448\u0438\u043c (\u043e\u0431 \u044d\u0442\u043e\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u0437\u043d\u0430\u043a&nbsp;<code>-<\/code>): \u043d\u043e\u0432\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432\u0432\u0435\u0440\u0445\u0443 \u0432\u044b\u0431\u043e\u0440\u043a\u0438;<\/li><li>\u0432 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u043f\u043e\u043f\u0430\u0434\u0443\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u044b\u0435 10 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0437 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430.<\/li><\/ul>\n\n\n\n<p>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043d\u0430 \u0431\u0435\u0437\u0443\u043f\u0440\u0435\u0447\u043d\u043e\u043c \u044f\u0437\u044b\u043a\u0435 Python, \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e SQL. \u0410 Django ORM \u043f\u0435\u0440\u0435\u0432\u0435\u0434\u0451\u0442 \u044d\u0442\u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 SQL:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>SELECT \n  'posts_post'.'id', \n  'posts_post'.'text', \n  'posts_post'.'pub_date', \n  'posts_post'.'author_id' \nFROM \n  'posts_post' \nORDER BY \n  'posts_post'.'pub_date' DESC  \nLIMIT 10 <\/code><\/pre>\n\n\n\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0432 \u043a\u043e\u0434 \u043a\u0430\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043a\u043b\u0430\u0441\u0441\u0430&nbsp;<strong>Post<\/strong>, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439&nbsp;<code>posts<\/code>&nbsp;\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435&nbsp;<code>context<\/code>&nbsp;\u043f\u043e\u0434 \u043a\u043b\u044e\u0447\u043e\u043c&nbsp;<code>'posts'<\/code>&nbsp;\u0432 \u0448\u0430\u0431\u043b\u043e\u043d&nbsp;<code>posts\/index.html<\/code>.\u0412 \u0448\u0430\u0431\u043b\u043e\u043d\u0435 \u0441\u043f\u0438\u0441\u043e\u043a, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u0439\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439&nbsp;<code>posts<\/code>, \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0432 \u0446\u0438\u043a\u043b\u0435. \u041d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u0418\u0437 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043f\u043e\u043b\u0435\u0439:<ul><li><code>post.author.get_full_name<\/code>&nbsp;\u2014 \u0432 \u043f\u043e\u043b\u0435&nbsp;<code>author<\/code>&nbsp;\u043c\u043e\u0434\u0435\u043b\u0438&nbsp;<strong>Post<\/strong>&nbsp;\u043f\u0435\u0440\u0435\u0434\u0430\u043d \u043e\u0431\u044a\u0435\u043a\u0442 \u043c\u043e\u0434\u0435\u043b\u0438&nbsp;<strong>User<\/strong>, \u0438\u0437 \u043d\u0435\u0433\u043e \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0435 \u0438\u043c\u044f \u0430\u0432\u0442\u043e\u0440\u0430;<\/li><li><code>post.pub_date<\/code>&nbsp;\u2014 \u0434\u0430\u0442\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438;<\/li><li><code>post.text<\/code>&nbsp;\u2014 \u043f\u043e\u043b\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u043f\u043e\u0441\u0442\u0430.<\/li><\/ul><\/li><li>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u0432\u044b\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043d\u0443\u0436\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430.<\/li><li>\u0415\u0441\u043b\u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f \u0446\u0438\u043a\u043b\u0430 (<code>not forloop.last<\/code>) \u2014 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0432\u043e\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0442\u0435\u0433&nbsp;<code>&lt;hr&gt;<\/code>&nbsp;\u2014&nbsp;<em><strong>h<\/strong>orizontal&nbsp;<strong>r<\/strong>ule<\/em>, \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u043b\u0438\u043d\u0438\u044f.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>{% for post in posts %}\n  &lt;ul&gt;\n    &lt;li&gt;\n      \u0410\u0432\u0442\u043e\u0440: {{ post.author.get_full_name }}\n    &lt;\/li&gt;\n    &lt;li&gt;\n      \u0414\u0430\u0442\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438: {{ post.pub_date|date:\"d E Y\" }}\n    &lt;\/li&gt;\n  &lt;\/ul&gt;\n  &lt;p&gt;{{ post.text }}&lt;\/p&gt;    \n  &lt;a href=\"\"&gt;\u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0433\u0440\u0443\u043f\u043f\u044b&lt;\/a&gt;\n  {% if not forloop.last %}&lt;hr&gt;{% endif %}\n{% endfor %} <\/code><\/pre>\n\n\n\n<p>\u041f\u043e\u0441\u043b\u0435 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043e\u0442\u0432\u0435\u0442\u043e\u043c \u043d\u0430 \u0435\u0433\u043e HTTP-\u0437\u0430\u043f\u0440\u043e\u0441.<\/p>\n\n\n\n<p>\u0412\u043e\u0442 \u0435\u0449\u0451 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0431\u0430\u0437\u044b:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>Post.objects.all()<\/code>\u00a0\u2014 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043c\u043e\u0434\u0435\u043b\u0438\u00a0<strong>Post<\/strong>.<\/li><li><code>Post.objects.get(id=1)<\/code>\u00a0\u2014 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u043c\u043e\u0434\u0435\u043b\u0438\u00a0<strong>Post<\/strong>, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f\u00a0<code>id<\/code>\u00a0\u0440\u0430\u0432\u043d\u043e 1. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u043e\u043b\u0435\u00a0<code>id<\/code>\u00a0\u2014 \u044d\u0442\u043e \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447, \u0430 Django \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0443 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u00a0<code>pk<\/code>, \u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u044d\u0442\u043e\u0433\u043e \u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0438\u043c:\u00a0<code>Post.objects.get(pk=1)<\/code>.<\/li><li><code>Post.objects.filter(pub_date__year=1854)<\/code>\u00a0\u2014 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u0435\u0440\u043d\u0451\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0433\u043e\u0434\u0430 \u0432 \u043f\u043e\u043b\u0435\u00a0<code>pub_date<\/code>\u00a0\u0440\u0430\u0432\u043d\u043e 1854. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438: \u0434\u0432\u043e\u0439\u043d\u043e\u0435 \u043d\u0438\u0436\u043d\u0435\u0435 \u043f\u043e\u0434\u0447\u0451\u0440\u043a\u0438\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f\u043c\u0438 \u043f\u043e\u043b\u044f \u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438\u00a0<code>filter()<\/code>\u00a0\u2014\u00a0<a href=\"https:\/\/docs.djangoproject.com\/en\/3.0\/ref\/models\/querysets\/#django.db.models.query.QuerySet.filter\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">\u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/li><li><code>Post.objects.filter(text__startswith='\u041f\u0438\u0441\u0430\u0442\u044c \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f')<\/code>\u00a0\u2014 \u043f\u0440\u0438\u043c\u0435\u0440 \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u043f\u043e \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u043c\u0443 \u043f\u043e\u043b\u044e, \u043e\u043d \u0432\u0435\u0440\u043d\u0451\u0442 \u0437\u0430\u043f\u0438\u0441\u0438, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0432 \u0444\u0438\u043b\u044c\u0442\u0440\u0435 \u0441\u0442\u0440\u043e\u043a\u0438.<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0411\u0414 \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u0438\u0437 \u043a\u043e\u0434\u0430 Python. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 Django ORM \u0435\u0441\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438\u0437 \u0411\u0414 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439. \u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0412 \u0444\u0430\u0439\u043b\u0435&nbsp;posts\/views.py&nbsp;\u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0435 view-\u0444\u0443\u043d\u043a\u0446\u0438\u044e&nbsp;index(): # posts\/views.py from django.http import HttpResponse # \u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043d\u0435\u0439 from .models import Post def index(request): # [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[187],"tags":[],"class_list":["post-18386","post","type-post","status-publish","format-standard","","category-uroki"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Django - \u0432\u044b\u0432\u043e\u0434 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/mob25.com\/blog\/django-vyvod-informacii-iz-bazy-dannyh\/\" \/>\n<meta property=\"og:locale\" content=\"ru_RU\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Django - \u0432\u044b\u0432\u043e\u0434 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445\" \/>\n<meta property=\"og:description\" content=\"\u0417\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0411\u0414 \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u0438\u0437 \u043a\u043e\u0434\u0430 Python. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 Django ORM \u0435\u0441\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438\u0437 \u0411\u0414 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439. \u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0412 \u0444\u0430\u0439\u043b\u0435&nbsp;posts\/views.py&nbsp;\u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0435 view-\u0444\u0443\u043d\u043a\u0446\u0438\u044e&nbsp;index(): # posts\/views.py from django.http import HttpResponse # \u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043d\u0435\u0439 from .models import Post def index(request): # [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mob25.com\/blog\/django-vyvod-informacii-iz-bazy-dannyh\/\" \/>\n<meta property=\"og:site_name\" content=\"\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-24T11:22:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-05-09T18:48:09+00:00\" \/>\n<meta name=\"author\" content=\"violet\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/mob25.com\/blog\/django-vyvod-informacii-iz-bazy-dannyh\/\",\"url\":\"https:\/\/mob25.com\/blog\/django-vyvod-informacii-iz-bazy-dannyh\/\",\"name\":\"Django - \u0432\u044b\u0432\u043e\u0434 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445\",\"isPartOf\":{\"@id\":\"https:\/\/mob25.com\/blog\/#website\"},\"datePublished\":\"2022-03-24T11:22:31+00:00\",\"dateModified\":\"2023-05-09T18:48:09+00:00\",\"author\":{\"@id\":\"https:\/\/mob25.com\/blog\/#\/schema\/person\/493391ea0717532d228de3cda6d7cf45\"},\"breadcrumb\":{\"@id\":\"https:\/\/mob25.com\/blog\/django-vyvod-informacii-iz-bazy-dannyh\/#breadcrumb\"},\"inLanguage\":\"ru-RU\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/mob25.com\/blog\/django-vyvod-informacii-iz-bazy-dannyh\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/mob25.com\/blog\/django-vyvod-informacii-iz-bazy-dannyh\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\",\"item\":\"https:\/\/mob25.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Django &#8212; \u0432\u044b\u0432\u043e\u0434 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mob25.com\/blog\/#website\",\"url\":\"https:\/\/mob25.com\/blog\/\",\"name\":\"\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mob25.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ru-RU\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/mob25.com\/blog\/#\/schema\/person\/493391ea0717532d228de3cda6d7cf45\",\"name\":\"violet\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ru-RU\",\"@id\":\"https:\/\/mob25.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d4571412769d757e8ecacdf5967ea55865839b6d95042f5fc535566d9d3533d0?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d4571412769d757e8ecacdf5967ea55865839b6d95042f5fc535566d9d3533d0?s=96&d=mm&r=g\",\"caption\":\"violet\"},\"url\":\"https:\/\/mob25.com\/blog\/author\/nkl\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Django - \u0432\u044b\u0432\u043e\u0434 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/mob25.com\/blog\/django-vyvod-informacii-iz-bazy-dannyh\/","og_locale":"ru_RU","og_type":"article","og_title":"Django - \u0432\u044b\u0432\u043e\u0434 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445","og_description":"\u0417\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0411\u0414 \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u043e \u0438\u0437 \u043a\u043e\u0434\u0430 Python. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 Django ORM \u0435\u0441\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438\u0437 \u0411\u0414 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439. \u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0412 \u0444\u0430\u0439\u043b\u0435&nbsp;posts\/views.py&nbsp;\u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0435 view-\u0444\u0443\u043d\u043a\u0446\u0438\u044e&nbsp;index(): # posts\/views.py from django.http import HttpResponse # \u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043d\u0435\u0439 from .models import Post def index(request): # [&hellip;]","og_url":"https:\/\/mob25.com\/blog\/django-vyvod-informacii-iz-bazy-dannyh\/","og_site_name":"\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438","article_published_time":"2022-03-24T11:22:31+00:00","article_modified_time":"2023-05-09T18:48:09+00:00","author":"violet","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/mob25.com\/blog\/django-vyvod-informacii-iz-bazy-dannyh\/","url":"https:\/\/mob25.com\/blog\/django-vyvod-informacii-iz-bazy-dannyh\/","name":"Django - \u0432\u044b\u0432\u043e\u0434 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445","isPartOf":{"@id":"https:\/\/mob25.com\/blog\/#website"},"datePublished":"2022-03-24T11:22:31+00:00","dateModified":"2023-05-09T18:48:09+00:00","author":{"@id":"https:\/\/mob25.com\/blog\/#\/schema\/person\/493391ea0717532d228de3cda6d7cf45"},"breadcrumb":{"@id":"https:\/\/mob25.com\/blog\/django-vyvod-informacii-iz-bazy-dannyh\/#breadcrumb"},"inLanguage":"ru-RU","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mob25.com\/blog\/django-vyvod-informacii-iz-bazy-dannyh\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/mob25.com\/blog\/django-vyvod-informacii-iz-bazy-dannyh\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430","item":"https:\/\/mob25.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Django &#8212; \u0432\u044b\u0432\u043e\u0434 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445"}]},{"@type":"WebSite","@id":"https:\/\/mob25.com\/blog\/#website","url":"https:\/\/mob25.com\/blog\/","name":"\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mob25.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ru-RU"},{"@type":"Person","@id":"https:\/\/mob25.com\/blog\/#\/schema\/person\/493391ea0717532d228de3cda6d7cf45","name":"violet","image":{"@type":"ImageObject","inLanguage":"ru-RU","@id":"https:\/\/mob25.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d4571412769d757e8ecacdf5967ea55865839b6d95042f5fc535566d9d3533d0?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d4571412769d757e8ecacdf5967ea55865839b6d95042f5fc535566d9d3533d0?s=96&d=mm&r=g","caption":"violet"},"url":"https:\/\/mob25.com\/blog\/author\/nkl\/"}]}},"_links":{"self":[{"href":"https:\/\/mob25.com\/blog\/wp-json\/wp\/v2\/posts\/18386","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mob25.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mob25.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mob25.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mob25.com\/blog\/wp-json\/wp\/v2\/comments?post=18386"}],"version-history":[{"count":0,"href":"https:\/\/mob25.com\/blog\/wp-json\/wp\/v2\/posts\/18386\/revisions"}],"wp:attachment":[{"href":"https:\/\/mob25.com\/blog\/wp-json\/wp\/v2\/media?parent=18386"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mob25.com\/blog\/wp-json\/wp\/v2\/categories?post=18386"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mob25.com\/blog\/wp-json\/wp\/v2\/tags?post=18386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}