{"title":"첫 번째 장고 앱 작성하기, part 1","version":"5.1","locale":"ko","docname":"intro/tutorial01","url":"/ko/5.1/intro/tutorial01/","canonical":"https://djangodocs.dev/ko/5.1/intro/tutorial01/","summary":"예제로 배워봅시다. 이 튜토리얼을 통해, 간단한 설문조사(Polls) 어플리케이션을 만드는 과정을 따라해 보겠습니다. 두 파트로 구성되어 있습니다.","html":"<h1>첫 번째 장고 앱 작성하기, part 1<a class=\"heading-anchor\" href=\"#writing-your-first-django-app-part-1\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>예제로 배워봅시다.</p>\n<p>이 튜토리얼을 통해, 간단한 설문조사(Polls) 어플리케이션을 만드는 과정을 따라해 보겠습니다.</p>\n<p>두 파트로 구성되어 있습니다.</p>\n<ul class=\"simple\">\n<li><p>사람들이 설문 내용을 보고 직접 투표할 수 있는 개방된 사이트</p></li>\n<li><p>관리자가 설문을 추가, 변경, 삭제할 수 있는 관리용 사이트</p></li>\n</ul>\n<p><a class=\"reference internal\" href=\"/ko/5.1/intro/install/\"><span class=\"doc\">Django 설치</span></a>가 되어 있다고 가정합니다. 쉘 프롬프트 ($ 접두사로 표시)에서 다음 명령을 실행하여 Django가 설치되어 있고 어떤 버전인지 알 수 있습니다.</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-0-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>python -m django --version\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-0-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> py -m django --version\n</code></pre></div></div></div>\n<p>Django가 설치 되었다면, 설치된 Django의 버전을 확인할 수 있습니다. 만약 설치가 제대로 되지 않았다면, “No module named django”와 같은 에러가 발생합니다.</p>\n<p>This tutorial is written for Django 5.1, which supports Python 3.10 and\nlater. If the Django version doesn’t match, you can refer to the tutorial for\nyour version of Django by using the version switcher at the bottom right corner\nof this page, or update Django to the newest version. If you’re using an older\nversion of Python, check <a class=\"reference internal\" href=\"/ko/5.1/faq/install/#faq-python-version-support\"><span class=\"std std-ref\">장고와 어떤 파이썬 버전을 사용해야 하나요?</span></a> to find a compatible\nversion of Django.</p>\n<aside class=\"admonition-where-to-get-help admonition\" role=\"note\">\n<p class=\"admonition-title\">도움을 받을 수 있는 방법</p>\n<p>이 튜토리얼을 수행하는 데 문제가 있는 경우 FAQ 섹션인 :doc:<a href=\"#id1\"><span class=\"problematic\" id=\"id2\">`</span></a>Getting Help &lt;/faq/help&gt;`으로 이동하십시오.</p>\n</aside>\n<section id=\"creating-a-project\">\n<h2>프로젝트 만들기<a class=\"heading-anchor\" href=\"#creating-a-project\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Django를 처음 사용한다면, 초기 설정에 주의를 기울여야 합니다. Django <a class=\"reference internal\" href=\"/ko/5.1/glossary/#term-project\"><span class=\"xref std std-term\">project</span></a>를 구성하는 코드를 자동 생성해야 하는데, 이 과정에서 데이터베이스 설정, Django 위한 옵션들, 어플리케이션을 위한 설정들과 같은 Django 인스턴스를 구성하는 수많은 설정들이 생성되기 때문입니다.</p>\n<p>From the command line, <code class=\"docutils literal notranslate\">cd</code> into a directory where you’d like to store your\ncode and create a new directory named <code class=\"docutils literal notranslate\">djangotutorial</code>. (This directory name\ndoesn’t matter to Django; you can rename it to anything you like.)</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-1-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>mkdir djangotutorial\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-1-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> <span class=\"k\">mkdir</span> djangotutorial\n</code></pre></div></div></div>\n<p>Then, run the following command to bootstrap a new Django project:</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-2-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>django-admin startproject mysite djangotutorial\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-2-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> django-admin startproject mysite djangotutorial\n</code></pre></div></div></div>\n<p>This will create a project called <code class=\"docutils literal notranslate\">mysite</code> inside the <code class=\"docutils literal notranslate\">djangotutorial</code>\ndirectory. If it didn’t work, see <a class=\"reference internal\" href=\"/ko/5.1/faq/troubleshooting/#troubleshooting-django-admin\"><span class=\"std std-ref\">django-admin을 실행하는 데 문제가 있습니다.</span></a>.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">참고</p>\n<p>프로젝트를 생성할 때, Python 또는 Django에서 사용 중인 이름은 피해야 합니다. 특히, <code class=\"docutils literal notranslate\">django</code>(Django 그 자체와 충돌이 일어납니다)나, <code class=\"docutils literal notranslate\">test</code>(Python 패키지의 이름중 하나입니다) 같은 이름은 피해야 한다는 의미입니다.</p>\n</aside>\n<p>:djadmin:<a href=\"#id1\"><span class=\"problematic\" id=\"id2\">`</span></a>startproject`에서 무엇이 생성되는지 확인해 봅시다.</p>\n<div class=\"code-block\" data-language=\"text\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Text</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Text code\"><code>djangotutorial/\n    manage.py\n    mysite/\n        __init__.py\n        settings.py\n        urls.py\n        asgi.py\n        wsgi.py\n</code></pre></div>\n<p>이 파일들은,</p>\n<ul class=\"simple\">\n<li><p><code class=\"file docutils literal notranslate\">manage.py</code>: Django 프로젝트와 다양한 방법으로 상호작용 하는 커맨드라인의 유틸리티 입니다. <code class=\"file docutils literal notranslate\">manage.py</code> 에 대한 자세한 정보는 <a class=\"reference internal\" href=\"/ko/5.1/ref/django-admin/\"><span class=\"doc\">django-admin and manage.py</span></a> 에서 확인할 수 있습니다.</p></li>\n<li><p><code class=\"file docutils literal notranslate\">mysite/</code>: A directory that is the actual Python package for your\nproject. Its name is the Python package name you’ll need to use to import\nanything inside it (e.g. <code class=\"docutils literal notranslate\">mysite.urls</code>).</p></li>\n<li><p><code class=\"file docutils literal notranslate\">mysite/__init__.py</code>: Python으로 하여금 이 디렉토리를 패키지처럼 다루라고 알려주는 용도의 단순한 빈 파일입니다. Python 초심자라면, Python 공식 홈페이지의 <a class=\"reference external\" href=\"https://docs.python.org/3/tutorial/modules.html#tut-packages\" title=\"(Python v3.14에서)\"><span class=\"xref std std-ref\">패키지</span></a>를 읽어보세요.</p></li>\n<li><p><code class=\"file docutils literal notranslate\">mysite/settings.py</code>: 현재 Django 프로젝트의 환경 및 구성을 저장합니다. <a class=\"reference internal\" href=\"/ko/5.1/topics/settings/\"><span class=\"doc\">Django settings</span></a>에서 환경 설정이 어떻게 동작하는지 확인할 수 있습니다.</p></li>\n<li><p><code class=\"file docutils literal notranslate\">mysite/urls.py</code>: 현재 Django project 의 URL 선언을 저장합니다. Django 로 작성된 사이트의 “목차” 라고 할 수 있습니다. <a class=\"reference internal\" href=\"/ko/5.1/topics/http/urls/\"><span class=\"doc\">URL dispatcher</span></a> 에서 URL 에 대한 자세한 내용을 읽어보세요.</p></li>\n<li><p><code class=\"file docutils literal notranslate\">mysite/asgi.py</code>: 현재 프로젝트를 서비스하기 위한 ASGI-호환 웹 서버의 진입점입니다. 자세한 내용은 <a class=\"reference internal\" href=\"/ko/5.1/howto/deployment/asgi/\"><span class=\"doc\">ASGI를 사용하여 배포하는 방법</span></a> 를 참조하십시오.</p></li>\n<li><p><code class=\"file docutils literal notranslate\">mysite/wsgi.py</code>: 현재 프로젝트를 서비스하기 위한 WSGI 호환 웹 서버의 진입점입니다. <a class=\"reference internal\" href=\"/ko/5.1/howto/deployment/wsgi/\"><span class=\"doc\">WSGI를 사용하여 배포하는 방법</span></a>를 읽어보세요.</p></li>\n</ul>\n</section>\n<section id=\"the-development-server\">\n<h2>개발 서버<a class=\"heading-anchor\" href=\"#the-development-server\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Let’s verify your Django project works. Change into the <code class=\"file docutils literal notranslate\">djangotutorial</code>\ndirectory, if you haven’t already, and run the following commands:</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-3-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>python manage.py runserver\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-3-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> py manage.py runserver\n</code></pre></div></div></div>\n<p>커맨드라인에서 다음과 같은 출력을 볼 수 있습니다.</p>\n<pre class=\"literal-block\">Performing system checks...\n\nSystem check identified no issues (0 silenced).\n\nYou have unapplied migrations; your app may not work properly until they are applied.\nRun 'python manage.py migrate' to apply them.\n\n2026년 08월 09일 - 15:50:53\nDjango version 5.1, using settings 'mysite.settings'\nStarting development server at <a class=\"reference external\" href=\"http://127.0.0.1:8000/\">http://127.0.0.1:8000/</a>\nQuit the server with CONTROL-C.</pre>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">참고</p>\n<p>현재 데이터베이스에 적용되지 않은 변경사항들(migrations)에 대한 경고들은 무시해도 됩니다. 데이터베이스에 대한 부분은 간단히 다루도록 하겠습니다.</p>\n</aside>\n<p>이제 서버가 실행 중이니 웹 브라우저의 <a class=\"reference external\" href=\"http://127.0.0.1:8000/\">http://127.0.0.1:8000/</a> 를 통해 접속할 수 있습니다. 여러분은 로켓이 이륙하는 “Congratulations!” 페이지가 보일 것입니다. 잘 동작하네요!</p>\n<p>Django 개발 서버를 시작했습니다. 개발 서버는 순수 Python으로 작성된 경량 웹 서버입니다. 운영 준비가 될 때까지 Apache와 같은 운영 서버를 구성할 필요 없이 신속하게 개발할 수 있도록 Django에 포함했습니다.</p>\n<p>이쯤에서 하나 기억할 것이 있습니다. 이 서버를 운영 환경과 유사한 환경에서 <strong>사용하지 마십시오.</strong> 개발 중에만 사용할 수 있도록 되어 있습니다. (우리는 웹 서버가 아닌 웹 프레임워크를 만드는 사업을 하고 있습니다.)</p>\n<p>(To serve the site on a different port, see the <a class=\"reference internal\" href=\"/ko/5.1/ref/django-admin/#django-admin-runserver\"><code class=\"xref std std-djadmin docutils literal notranslate\">runserver</code></a> reference.)</p>\n<aside class=\"admonition-automatic-reloading-of-djadmin-runserver admonition\" role=\"note\">\n<p class=\"admonition-title\"><a class=\"reference internal\" href=\"/ko/5.1/ref/django-admin/#django-admin-runserver\"><code class=\"xref std std-djadmin docutils literal notranslate\">runserver</code></a> 의 자동 변경 기능</p>\n<p>개발 서버는 요청이 들어올 때마다 자동으로 Python 코드를 다시 불러옵니다. 코드의 변경사항을 반영하기 위해서 굳이 서버를 재기동 하지 않아도 됩니다. 그러나, 파일을 추가하는 등의 몇몇의 동작은 개발서버가 자동으로 인식하지 못하기 때문에, 이런 상황에서는 서버를 재기동 해야 적용됩니다.</p>\n</aside>\n</section>\n<section id=\"creating-the-polls-app\">\n<h2>설문조사 앱 만들기<a class=\"heading-anchor\" href=\"#creating-the-polls-app\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>이제, 작업을 시작하기 위해 당신의 환경(프로젝트)이 설치되었습니다.</p>\n<p>Django에서 당신이 작성하는 각 어플리케이션들은 다음과 같은 관례로 Python 패키지가 구성됩니다. Django 는 앱(app) 의 기본 디렉토리 구조를 자동으로 생성할 수 있는 도구를 제공하기 때문에, 코드에만 더욱 집중할 수 있습니다.</p>\n<aside class=\"admonition-projects-vs-apps admonition\" role=\"note\">\n<p class=\"admonition-title\">프로젝트 대 앱</p>\n<p>프로젝트와 앱은 무엇이 다를까요? 앱은 블로그 시스템, 공개 기록 데이터베이스 또는 소규모 의견조사 앱과 같은 작업을 수행하는 웹 애플리케이션입니다. 프로젝트는 특정 웹 사이트에 대한 구성 및 앱의 모음입니다. 한 프로젝트에 여러 개의 앱이 포함될 수 있습니다. 앱은 여러 프로젝트에 있을 수 있습니다.</p>\n</aside>\n<p>Your apps can live anywhere in your <a class=\"reference external\" href=\"https://docs.python.org/3/tutorial/modules.html#tut-searchpath\" title=\"(Python v3.14에서)\"><span class=\"xref std std-ref\">Python path</span></a>. In\nthis tutorial, we’ll create our poll app inside the <code class=\"docutils literal notranslate\">djangotutorial</code> folder.</p>\n<p>앱을 생성하기 위해 <code class=\"file docutils literal notranslate\">manage.py</code>가 존재하는 디렉토리에서 다음의 명령을 입력해 봅시다.</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-4-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>python manage.py startapp polls\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-4-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> py manage.py startapp polls\n</code></pre></div></div></div>\n<p>그러면 디렉토리 :file:<a href=\"#id1\"><span class=\"problematic\" id=\"id2\">`</span></a>polls`가 생성되며, 이 디렉토리는 다음과 같이 배치됩니다.</p>\n<div class=\"code-block\" data-language=\"text\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Text</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Text code\"><code>polls/\n    __init__.py\n    admin.py\n    apps.py\n    migrations/\n        __init__.py\n    models.py\n    tests.py\n    views.py\n</code></pre></div>\n<p>이 디렉토리 구조는 투표 어플리케이션의 집이 되어줄 것입니다.</p>\n</section>\n<section id=\"write-your-first-view\">\n<h2>첫 번째 뷰 작성하기<a class=\"heading-anchor\" href=\"#write-your-first-view\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>첫 번째 뷰를 작성해봅시다. “polls/view.py”를 열어 다음과 같은 파이썬 코드를 입력합니다</p>\n<figure class=\"code-block code-block-captioned\" data-language=\"python\"><figcaption class=\"code-block-caption\"><code class=\"docutils literal notranslate\">polls/views.py</code></figcaption>\n<div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Python code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.http</span> <span class=\"kn\">import</span> HttpResponse\n\n\n<span class=\"k\">def</span> <span class=\"nf\">index</span><span class=\"p\">(</span>request<span class=\"p\">):</span>\n    <span class=\"k\">return</span> HttpResponse<span class=\"p\">(</span><span class=\"s2\">&quot;Hello, world. You&#39;re at the polls index.&quot;</span><span class=\"p\">)</span>\n</code></pre></figure>\n<p>This is the most basic view possible in Django. To access it in a browser, we\nneed to map it to a URL - and for this we need to define a URL configuration,\nor “URLconf” for short. These URL configurations are defined inside each\nDjango app, and they are Python files named <code class=\"docutils literal notranslate\">urls.py</code>.</p>\n<p>To define a URLconf for the <code class=\"docutils literal notranslate\">polls</code> app, create a file <code class=\"docutils literal notranslate\">polls/urls.py</code>\nwith the following content:</p>\n<figure class=\"code-block code-block-captioned\" data-language=\"python\"><figcaption class=\"code-block-caption\"><code class=\"docutils literal notranslate\">polls/urls.py</code></figcaption>\n<div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Python code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.urls</span> <span class=\"kn\">import</span> path\n\n<span class=\"kn\">from</span> <span class=\"nn\">.</span> <span class=\"kn\">import</span> views\n\nurlpatterns <span class=\"o\">=</span> <span class=\"p\">[</span>\n    path<span class=\"p\">(</span><span class=\"s2\">&quot;&quot;</span><span class=\"p\">,</span> views<span class=\"o\">.</span>index<span class=\"p\">,</span> name<span class=\"o\">=</span><span class=\"s2\">&quot;index&quot;</span><span class=\"p\">),</span>\n<span class=\"p\">]</span>\n</code></pre></figure>\n<p>Your app directory should now look like:</p>\n<div class=\"code-block\" data-language=\"text\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Text</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Text code\"><code>polls/\n    __init__.py\n    admin.py\n    apps.py\n    migrations/\n        __init__.py\n    models.py\n    tests.py\n    urls.py\n    views.py\n</code></pre></div>\n<p>The next step is to configure the global URLconf in the <code class=\"docutils literal notranslate\">mysite</code> project to\ninclude the URLconf defined in <code class=\"docutils literal notranslate\">polls.urls</code>. To do this, add an import for\n<code class=\"docutils literal notranslate\">django.urls.include</code> in <code class=\"docutils literal notranslate\">mysite/urls.py</code> and insert an\n<a class=\"reference internal\" href=\"/ko/5.1/ref/urls/#django.urls.include\" title=\"django.urls.include\"><code class=\"xref py py-func docutils literal notranslate\">include()</code></a> in the <code class=\"docutils literal notranslate\">urlpatterns</code> list, so you have:</p>\n<figure class=\"code-block code-block-captioned\" data-language=\"python\"><figcaption class=\"code-block-caption\"><code class=\"docutils literal notranslate\">mysite/urls.py</code></figcaption>\n<div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Python code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.contrib</span> <span class=\"kn\">import</span> admin\n<span class=\"kn\">from</span> <span class=\"nn\">django.urls</span> <span class=\"kn\">import</span> include<span class=\"p\">,</span> path\n\nurlpatterns <span class=\"o\">=</span> <span class=\"p\">[</span>\n    path<span class=\"p\">(</span><span class=\"s2\">&quot;polls/&quot;</span><span class=\"p\">,</span> include<span class=\"p\">(</span><span class=\"s2\">&quot;polls.urls&quot;</span><span class=\"p\">)),</span>\n    path<span class=\"p\">(</span><span class=\"s2\">&quot;admin/&quot;</span><span class=\"p\">,</span> admin<span class=\"o\">.</span>site<span class=\"o\">.</span>urls<span class=\"p\">),</span>\n<span class=\"p\">]</span>\n</code></pre></figure>\n<p>The <a class=\"reference internal\" href=\"/ko/5.1/ref/urls/#django.urls.path\" title=\"django.urls.path\"><code class=\"xref py py-func docutils literal notranslate\">path()</code></a> function expects at least two arguments:\n<code class=\"docutils literal notranslate\">route</code> and <code class=\"docutils literal notranslate\">view</code>.\nThe <a class=\"reference internal\" href=\"/ko/5.1/ref/urls/#django.urls.include\" title=\"django.urls.include\"><code class=\"xref py py-func docutils literal notranslate\">include()</code></a> function allows referencing other URLconfs.\nWhenever Django encounters <a class=\"reference internal\" href=\"/ko/5.1/ref/urls/#django.urls.include\" title=\"django.urls.include\"><code class=\"xref py py-func docutils literal notranslate\">include()</code></a>, it chops off whatever\npart of the URL matched up to that point and sends the remaining string to the\nincluded URLconf for further processing.</p>\n<p><a class=\"reference internal\" href=\"/ko/5.1/ref/urls/#django.urls.include\" title=\"django.urls.include\"><code class=\"xref py py-func docutils literal notranslate\">include()</code></a>에 숨은 아이디어 덕분에 URL을 쉽게 연결할 수 있습니다. polls 앱에 그 자체의 URLconf(<code class=\"docutils literal notranslate\">polls/urls.py</code>)가 존재하는 한, “/polls/”, 또는 “/fun_polls/”, “/content/polls/”와 같은 경로, 또는 그 어떤 다른 root 경로에 연결하더라도, 앱은 여전히 잘 동작할 것입니다.</p>\n<aside class=\"admonition-when-to-use-func-django-urls-include admonition\" role=\"note\">\n<p class=\"admonition-title\">언제 <a class=\"reference internal\" href=\"/ko/5.1/ref/urls/#django.urls.include\" title=\"django.urls.include\"><code class=\"xref py py-func docutils literal notranslate\">include()</code></a>를 사용해야 하나요?</p>\n<p>You should always use <code class=\"docutils literal notranslate\">include()</code> when you include other URL patterns.\nThe only exception is <code class=\"docutils literal notranslate\">admin.site.urls</code>, which is a pre-built URLconf\nprovided by Django for the default admin site.</p>\n</aside>\n<p>이제 <code class=\"docutils literal notranslate\">index</code> 뷰가 URLconf에 연결되었습니다. 잘 작동하는지 확인하기 위해 다음 명령을 입력해 보세요.</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-5-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span>python manage.py runserver\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-5-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> py manage.py runserver\n</code></pre></div></div></div>\n<p>브라우저에서 <a class=\"reference external\" href=\"http://localhost:8000/polls/\">http://localhost:8000/polls/</a>를 입력하면 <code class=\"docutils literal notranslate\">index</code> 뷰에 정의한 “<em>Hello, world. You’re at the polls index.</em>” 가 보일 것입니다.</p>\n<aside class=\"admonition-page-not-found admonition\" role=\"note\">\n<p class=\"admonition-title\">페이지가 보이지 않나요?</p>\n<p>에러 페이지가 표시된다면, <a class=\"reference external\" href=\"http://localhost:8000/\">http://localhost:8000/</a> 이 아니라 <a class=\"reference external\" href=\"http://localhost:8000/polls\">http://localhost:8000/polls</a>/가 정확히 주소 창에 입력되었는지 확인하세요.</p>\n</aside>\n<p>request 와 response 의 기본 흐름을 이해하셨다면, <a class=\"reference internal\" href=\"/ko/5.1/intro/tutorial02/\"><span class=\"doc\">튜토리얼 2장</span></a> 에서 데이터베이스 작업을 시작해보세요.</p>\n</section>","rootId":"writing-your-first-django-app-part-1","toc":[{"title":"프로젝트 만들기","anchor":"creating-a-project","children":[]},{"title":"개발 서버","anchor":"the-development-server","children":[]},{"title":"설문조사 앱 만들기","anchor":"creating-the-polls-app","children":[]},{"title":"첫 번째 뷰 작성하기","anchor":"write-your-first-view","children":[]}],"breadcrumbs":[{"docname":"intro/index","title":"시작하기","url":"/ko/5.1/intro/"}],"prev":{"docname":"intro/install","title":"빠른 설치 가이드","url":"/ko/5.1/intro/install/"},"next":{"docname":"intro/tutorial02","title":"첫 번째 장고 앱 작성하기, part 2","url":"/ko/5.1/intro/tutorial02/"},"formats":{"html":"/ko/5.1/intro/tutorial01/","markdown":"/ko/5.1/intro/tutorial01.md","json":"/ko/5.1/intro/tutorial01.json"},"source":"https://github.com/django/django/blob/stable/5.1.x/docs/intro/tutorial01.txt","official":"https://docs.djangoproject.com/ko/5.1/intro/tutorial01/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11"],"inLocales":["en","zh-hans","fr","ja","id","it","pt-br","ko","es","el","pl"]}